Skip to content

Commit d343029

Browse files
committed
Remove unnecessary __del__ handlers
There normally should be no logic attached to del. Cleanly disconnecting network resources is not needed at that time.
1 parent 35b7e09 commit d343029

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

redis/asyncio/connection.py

Lines changed: 0 additions & 18 deletions
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)