diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2020-05-20 11:04:48 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2020-05-20 11:04:48 -0700 |
commit | afb3b81dca308307a17409a0a97bb52b070716b8 (patch) | |
tree | 856e60aef5e5a850ebc09262ba915743efef3798 /redis/connection.py | |
parent | 7c0a67a5cb4a20aea44c590837b0e79c9c09c510 (diff) | |
download | redis-py-afb3b81dca308307a17409a0a97bb52b070716b8.tar.gz |
Restore try/except in __del__ methods
Fixed #1339
Diffstat (limited to 'redis/connection.py')
-rwxr-xr-x | redis/connection.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/redis/connection.py b/redis/connection.py index 9781b8c..5c8fd3c 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -296,7 +296,10 @@ class PythonParser(BaseParser): self._buffer = None def __del__(self): - self.on_disconnect() + try: + self.on_disconnect() + except Exception: + pass def on_connect(self, connection): "Called when the socket connects" @@ -374,7 +377,10 @@ class HiredisParser(BaseParser): self._buffer = bytearray(socket_read_size) def __del__(self): - self.on_disconnect() + try: + self.on_disconnect() + except Exception: + pass def on_connect(self, connection): self._sock = connection._sock @@ -534,7 +540,10 @@ class Connection(object): return pieces def __del__(self): - self.disconnect() + try: + self.disconnect() + except Exception: + pass def register_connect_callback(self, callback): self._connect_callbacks.append(callback) |