[PR #422] [MERGED] fix: Invoke cleanup() method on the message queue from deploy() before exiting #454

Closed
opened 2026-02-16 01:17:25 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/run-llama/llama_deploy/pull/422
Author: @masci
Created: 1/7/2025
Status: Merged
Merged: 1/7/2025
Merged by: @masci

Base: mainHead: massi/tidy-up-message-queue


📝 Commits (4)

  • efe641c fix: proper shutdown message queues on deploy()
  • c2f5c07 removed unused methods
  • e3f3676 tidy up deploy() shutdown
  • a425778 fix naming

📊 Changes

23 files changed (+66 additions, -174 deletions)

View changed files

📝 e2e_tests/message_queues/kafka/__init__.py (+0 -0)
📝 e2e_tests/message_queues/kafka/conftest.py (+0 -0)
📝 e2e_tests/message_queues/kafka/docker-compose.yml (+0 -0)
📝 e2e_tests/message_queues/kafka/test_message_queue.py (+0 -0)
📝 e2e_tests/message_queues/kafka/workflow.py (+0 -0)
📝 e2e_tests/message_queues/rabbitmq/__init__.py (+0 -0)
📝 e2e_tests/message_queues/rabbitmq/conftest.py (+0 -0)
📝 e2e_tests/message_queues/rabbitmq/docker-compose.yml (+0 -0)
📝 e2e_tests/message_queues/rabbitmq/test_message_queue.py (+0 -0)
📝 e2e_tests/message_queues/rabbitmq/workflow.py (+0 -0)
📝 e2e_tests/message_queues/simple/__init__.py (+0 -0)
📝 e2e_tests/message_queues/simple/test_message_queue.py (+0 -0)
📝 llama_deploy/control_plane/server.py (+5 -1)
📝 llama_deploy/deploy/deploy.py (+21 -44)
📝 llama_deploy/message_queues/apache_kafka.py (+5 -16)
📝 llama_deploy/message_queues/aws.py (+5 -25)
📝 llama_deploy/message_queues/base.py (+1 -14)
📝 llama_deploy/message_queues/rabbitmq.py (+5 -19)
📝 llama_deploy/message_queues/redis.py (+2 -17)
📝 llama_deploy/message_queues/simple/client.py (+4 -7)

...and 3 more files

📄 Description

Message queue clients have a method that's supposed to be invoked on exit to clean up the queue if needed (depending on the queue implementation). The method wasn't called from deploy() and while this is ok-ish most of the times, while working on the Redis message queue I noted the redis client is not happy without a proper shutdown of its client connections, and my e2e tests were failing.

With this PR:

  • cleanup_local was renamed to cleanup to avoid confusion (cleanup also happens when server is remote)
  • cleanup is called from deploy() on shutdown

This way, all the e2e tests currently relying on deploy() will implicitly clean up the queue on exit, improving coverage.

Also in this PR:

  • The shutdown procedure in deploy() was refactored to rely on CancelledError instead of SIGTERM in a more asyncio-friendly fashion
  • The control plane server now exits gracefully when interrupted
  • The e2e tests modules for the message queues where renamed to avoid stuttering

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/run-llama/llama_deploy/pull/422 **Author:** [@masci](https://github.com/masci) **Created:** 1/7/2025 **Status:** ✅ Merged **Merged:** 1/7/2025 **Merged by:** [@masci](https://github.com/masci) **Base:** `main` ← **Head:** `massi/tidy-up-message-queue` --- ### 📝 Commits (4) - [`efe641c`](https://github.com/run-llama/llama_deploy/commit/efe641ce3ac04c06ed8c5f57233d5237c7d80822) fix: proper shutdown message queues on deploy() - [`c2f5c07`](https://github.com/run-llama/llama_deploy/commit/c2f5c07225bfe0cf2ad5b90e97c9dd03c07ad60e) removed unused methods - [`e3f3676`](https://github.com/run-llama/llama_deploy/commit/e3f3676d997fc5b6b5984338284da090feb2b46f) tidy up deploy() shutdown - [`a425778`](https://github.com/run-llama/llama_deploy/commit/a425778c89ef95f2ef70ec049e9765998db64909) fix naming ### 📊 Changes **23 files changed** (+66 additions, -174 deletions) <details> <summary>View changed files</summary> 📝 `e2e_tests/message_queues/kafka/__init__.py` (+0 -0) 📝 `e2e_tests/message_queues/kafka/conftest.py` (+0 -0) 📝 `e2e_tests/message_queues/kafka/docker-compose.yml` (+0 -0) 📝 `e2e_tests/message_queues/kafka/test_message_queue.py` (+0 -0) 📝 `e2e_tests/message_queues/kafka/workflow.py` (+0 -0) 📝 `e2e_tests/message_queues/rabbitmq/__init__.py` (+0 -0) 📝 `e2e_tests/message_queues/rabbitmq/conftest.py` (+0 -0) 📝 `e2e_tests/message_queues/rabbitmq/docker-compose.yml` (+0 -0) 📝 `e2e_tests/message_queues/rabbitmq/test_message_queue.py` (+0 -0) 📝 `e2e_tests/message_queues/rabbitmq/workflow.py` (+0 -0) 📝 `e2e_tests/message_queues/simple/__init__.py` (+0 -0) 📝 `e2e_tests/message_queues/simple/test_message_queue.py` (+0 -0) 📝 `llama_deploy/control_plane/server.py` (+5 -1) 📝 `llama_deploy/deploy/deploy.py` (+21 -44) 📝 `llama_deploy/message_queues/apache_kafka.py` (+5 -16) 📝 `llama_deploy/message_queues/aws.py` (+5 -25) 📝 `llama_deploy/message_queues/base.py` (+1 -14) 📝 `llama_deploy/message_queues/rabbitmq.py` (+5 -19) 📝 `llama_deploy/message_queues/redis.py` (+2 -17) 📝 `llama_deploy/message_queues/simple/client.py` (+4 -7) _...and 3 more files_ </details> ### 📄 Description Message queue clients have a method that's supposed to be invoked on exit to clean up the queue if needed (depending on the queue implementation). The method wasn't called from `deploy()` and while this is ok-ish most of the times, while working on the Redis message queue I noted the redis client is not happy without a proper shutdown of its client connections, and my e2e tests were failing. With this PR: - `cleanup_local` was renamed to `cleanup` to avoid confusion (cleanup also happens when server is remote) - `cleanup` is called from `deploy()` on shutdown This way, all the e2e tests currently relying on `deploy()` will implicitly clean up the queue on exit, improving coverage. Also in this PR: - The shutdown procedure in `deploy()` was refactored to rely on `CancelledError` instead of `SIGTERM` in a more asyncio-friendly fashion - The control plane server now exits gracefully when interrupted - The e2e tests modules for the message queues where renamed to avoid stuttering --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 01:17:25 -05:00
yindo closed this issue 2026-02-16 01:17:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_deploy#454