From 021222475b1cf3c866a7c04ff22996845567a26e Mon Sep 17 00:00:00 2001 From: Julius Unverfehrt Date: Tue, 16 Apr 2024 16:20:05 +0200 Subject: [PATCH] fix: add error handling for file not found error When a file couldn't be downloaded from storage, the queue consumer now informs the operator with a log and rejects the message, without crashing but continuing its honest work. --- pyinfra/queue/manager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyinfra/queue/manager.py b/pyinfra/queue/manager.py index b71f0bd..bb30d1d 100644 --- a/pyinfra/queue/manager.py +++ b/pyinfra/queue/manager.py @@ -184,6 +184,9 @@ class QueueManager: channel.basic_ack(delivery_tag=method.delivery_tag) logger.debug(f"Message with {method.delivery_tag=} acknowledged.") + except FileNotFoundError as e: + logger.warning(f"{e}, declining message with {method.delivery_tag=}.") + channel.basic_nack(method.delivery_tag, requeue=False) except Exception: logger.warning(f"Failed to process message with {method.delivery_tag=}, declining...", exc_info=True) channel.basic_nack(method.delivery_tag, requeue=False)