From 2b37a35f7152725afa36f804638b34852e8a4dd2 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 12 Dec 2023 11:43:51 -0500 Subject: [PATCH] queue: Only NAK the events if the channel is still open. If the exception was because the channel closed, attempting to NAK the events will just raise another error, and is pointless, as the server already marked the pending events as NAK'd. --- zerver/lib/queue.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zerver/lib/queue.py b/zerver/lib/queue.py index a00a1b18c4..ca96796852 100644 --- a/zerver/lib/queue.py +++ b/zerver/lib/queue.py @@ -217,7 +217,8 @@ class SimpleQueueClient(QueueClient[BlockingChannel]): callback(events) channel.basic_ack(max_processed, multiple=True) except BaseException: - channel.basic_nack(max_processed, multiple=True) + if channel.is_open: + channel.basic_nack(max_processed, multiple=True) raise events = [] last_process = now