Skip to content

Commit db7b9dd

Browse files
Issue #2749: Remove unnecessary __del__ handlers (#2755)
* Remove unnecessary __del__ handlers There normally should be no logic attached to del. Cleanly disconnecting network resources is not needed at that time. * add CHANGES
1 parent 2d9b5ac commit db7b9dd

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

CHANGES

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Fix #2749, remove unnecessary __del__ logic to close connections.
12
* Fix #2754, adding a missing argument to SentinelManagedConnection
23
* Fix `xadd` command to accept non-negative `maxlen` including 0
34
* Revert #2104, #2673, add `disconnect_on_error` option to `read_response()` (issues #2506, #2624)

redis/asyncio/connection.py

-18
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ def __init__(self, socket_read_size: int):
181181
self._read_size = socket_read_size
182182
self._connected = False
183183

184-
def __del__(self):
185-
try:
186-
self.on_disconnect()
187-
except Exception:
188-
pass
189-
190184
@classmethod
191185
def parse_error(cls, response: str) -> ResponseError:
192186
"""Parse an error response"""
@@ -570,18 +564,6 @@ def repr_pieces(self):
570564
pieces.append(("client_name", self.client_name))
571565
return pieces
572566

573-
def __del__(self):
574-
try:
575-
if self.is_connected:
576-
loop = asyncio.get_running_loop()
577-
coro = self.disconnect()
578-
if loop.is_running():
579-
loop.create_task(coro)
580-
else:
581-
loop.run_until_complete(coro)
582-
except Exception:
583-
pass
584-
585567
@property
586568
def is_connected(self):
587569
return self._reader is not None and self._writer is not None

0 commit comments

Comments
 (0)