From 57d5aca1d27db91861fcd5a4d1bc20df2f661690 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Wed, 26 Jun 2024 17:07:52 +0330 Subject: [PATCH 1/2] fix: closing rabbitMQ connection! --- celery_app/utils/fire_event.py | 1 + 1 file changed, 1 insertion(+) diff --git a/celery_app/utils/fire_event.py b/celery_app/utils/fire_event.py index d975384..c3dfb64 100644 --- a/celery_app/utils/fire_event.py +++ b/celery_app/utils/fire_event.py @@ -37,3 +37,4 @@ def job_send(event: str, queue_name: str, content: dict[str, Any]) -> None: content=content, ) logging.info("Published to RabbitMQ!") + rabbit_mq.connection.close() From de9ca16bf6f1e2587cf69c5bf9d047eac9c465b4 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Dadgar <48308230+amindadgar@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:13:47 +0330 Subject: [PATCH 2/2] Update celery_app/utils/fire_event.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- celery_app/utils/fire_event.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/celery_app/utils/fire_event.py b/celery_app/utils/fire_event.py index c3dfb64..1cf7830 100644 --- a/celery_app/utils/fire_event.py +++ b/celery_app/utils/fire_event.py @@ -37,4 +37,7 @@ def job_send(event: str, queue_name: str, content: dict[str, Any]) -> None: content=content, ) logging.info("Published to RabbitMQ!") - rabbit_mq.connection.close() + try: + rabbit_mq.connection.close() + except Exception as e: + logging.error(f"Failed to close RabbitMQ connection: {e}")