diff --git a/pyinfra/queue/queue_manager.py b/pyinfra/queue/queue_manager.py index 7762ffc..5021114 100644 --- a/pyinfra/queue/queue_manager.py +++ b/pyinfra/queue/queue_manager.py @@ -3,6 +3,7 @@ import json import logging import signal from typing import Callable +from os import environ import pika import pika.exceptions @@ -58,7 +59,9 @@ class QueueManager(object): def _close_channel(self): self._channel.close() - self._connection.close() + + if environ.get("CLOSE_CONNECTION", False) == "True": + self._connection.close() def start_consuming(self, process_message_callback: Callable): self._open_channel()