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.
This commit is contained in:
Alex Vandiver 2023-12-12 11:43:51 -05:00 committed by Tim Abbott
parent 55b26da82b
commit 2b37a35f71
1 changed files with 2 additions and 1 deletions

View File

@ -217,7 +217,8 @@ class SimpleQueueClient(QueueClient[BlockingChannel]):
callback(events) callback(events)
channel.basic_ack(max_processed, multiple=True) channel.basic_ack(max_processed, multiple=True)
except BaseException: except BaseException:
channel.basic_nack(max_processed, multiple=True) if channel.is_open:
channel.basic_nack(max_processed, multiple=True)
raise raise
events = [] events = []
last_process = now last_process = now