diff --git a/pyinfra/queue/queue_manager.py b/pyinfra/queue/queue_manager.py index e6e0cef..a860d69 100644 --- a/pyinfra/queue/queue_manager.py +++ b/pyinfra/queue/queue_manager.py @@ -35,9 +35,9 @@ class QueueManager(object): def __init__(self, config: Config = CONFIG): connection_params = get_connection_params(config) - atexit.register(self.cancel_queue_subscription) - signal.signal(signal.SIGTERM, self.cancel_queue_subscription) - signal.signal(signal.SIGINT, self.cancel_queue_subscription) + atexit.register(self.stop_consuming) + signal.signal(signal.SIGTERM, self.stop_consuming) + signal.signal(signal.SIGINT, self.stop_consuming) self._connection = pika.BlockingConnection(parameters=connection_params) self._channel = self._connection.channel() @@ -67,9 +67,9 @@ class QueueManager(object): self._channel.start_consuming() finally: self.logger.warning("An unhandled exception occurred while consuming messages. Consuming will stop.") - self.cancel_queue_subscription() + self.stop_consuming() - def cancel_queue_subscription(self): + def stop_consuming(self): if self._consumer_token and self._connection: self.logger.info(f"Cancelling subscription for consumer-tag: {self._consumer_token}") self._channel.basic_cancel(self._consumer_token)