Skip to content

Commit

Permalink
Reformat __del__()
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Sep 18, 2023
1 parent 044aa9d commit c64bdb9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion redis/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ async def __aexit__(self, exc_type, exc_value, traceback):
# passing _warnings and _grl as argument default since they may be gone
# by the time __del__ is called at shutdown
def __del__(
self, _warn: Any = warnings.warn, _grl: Any = asyncio.get_running_loop
self,
_warn: Any = warnings.warn,
_grl: Any = asyncio.get_running_loop,
) -> None:
if hasattr(self, "connection") and (self.connection is not None):
_warn(f"Unclosed client session {self!r}", ResourceWarning, source=self)
Expand Down
8 changes: 6 additions & 2 deletions redis/asyncio/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,9 @@ def __await__(self) -> Generator[Any, None, "RedisCluster"]:
_DEL_MESSAGE = "Unclosed RedisCluster client"

def __del__(
self, _warn: Any = warnings.warn, _grl: Any = asyncio.get_running_loop
self,
_warn: Any = warnings.warn,
_grl: Any = asyncio.get_running_loop,
) -> None:
if hasattr(self, "_initialize") and not self._initialize:
_warn(f"{self._DEL_MESSAGE} {self!r}", ResourceWarning, source=self)
Expand Down Expand Up @@ -961,7 +963,9 @@ def __eq__(self, obj: Any) -> bool:
_DEL_MESSAGE = "Unclosed ClusterNode object"

def __del__(
self, _warn: Any = warnings.warn, _grl: Any = asyncio.get_running_loop
self,
_warn: Any = warnings.warn,
_grl: Any = asyncio.get_running_loop,
) -> None:
for connection in self._connections:
if connection.is_connected:
Expand Down

0 comments on commit c64bdb9

Please sign in to comment.