Skip to content

Commit

Permalink
Handle socket.timeout exception that happens on Python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
reidsunderland authored and petersilva committed Mar 11, 2024
1 parent 2f4d622 commit 491a6ca
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sarracenia/moth/amqpconsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import sarracenia
from sarracenia.moth.amqp import AMQP, amqp_ss_maxlen, default_options

import socket
import time
import queue

Expand Down Expand Up @@ -103,6 +104,10 @@ def getNewMessage(self) -> sarracenia.Message:
self.connection.drain_events(timeout=0.1) # TODO configurable timeout?
except TimeoutError:
pass
# In newer Python versions, socket.timeout is "a deprecated alias of TimeoutError", but it's not on
# older versions (3.6) and needs to be handled separately
except socket.timeout:
pass

try:
# don't block waiting for the queue to be available, better to just try again later
Expand Down

0 comments on commit 491a6ca

Please sign in to comment.