diff options
author | Michael Lazar <mlazar@doctorondemand.com> | 2021-12-15 13:18:11 -0500 |
---|---|---|
committer | Asif Saif Uddin <auvipy@gmail.com> | 2021-12-16 09:53:34 +0600 |
commit | f4fd4f952dded9ea1006e82642f2c15008bb68d3 (patch) | |
tree | 1181cc69a0ad3abf25b1054743c81a70b5d8c229 /amqp/transport.py | |
parent | be6b5ededa5654ca43cea67927667456e32523a3 (diff) | |
download | py-amqp-f4fd4f952dded9ea1006e82642f2c15008bb68d3.tar.gz |
Add additional error handling around code where an OSError may be raised on failed connections. Fixes #378
Diffstat (limited to 'amqp/transport.py')
-rw-r--r-- | amqp/transport.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/amqp/transport.py b/amqp/transport.py index 177fb22..b87f9fe 100644 --- a/amqp/transport.py +++ b/amqp/transport.py @@ -272,7 +272,11 @@ class _AbstractTransport: def close(self): if self.sock is not None: - self._shutdown_transport() + try: + self._shutdown_transport() + except OSError: + pass + # Call shutdown first to make sure that pending messages # reach the AMQP broker if the program exits after # calling this method. @@ -280,7 +284,11 @@ class _AbstractTransport: self.sock.shutdown(socket.SHUT_RDWR) except OSError: pass - self.sock.close() + + try: + self.sock.close() + except OSError: + pass self.sock = None self.connected = False |