Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Removed irrelevant/unnecessary code
Browse files Browse the repository at this point in the history
* Fixed getting proper event loop
  • Loading branch information
Andrew-Chen-Wang committed Dec 15, 2021
1 parent cb028e9 commit a121f9a
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions aioredis/client.py
Expand Up @@ -1057,21 +1057,14 @@ async def __aexit__(self, exc_type, exc_value, traceback):
_DEL_MESSAGE = "Unclosed Redis client"

def __del__(self, _warnings: Any = warnings) -> None:
try:
if self.connection is not None:
_warnings.warn(
f"Unclosed client session {self!r}",
ResourceWarning,
source=self,
)
context = {"client": self, "message": self._DEL_MESSAGE}
if self._source_traceback is not None:
context["source_traceback"] = self._source_traceback
self._loop.call_exception_handler(context)
except AttributeError:
# loop was not initialized yet,
# either self._connector or self._loop doesn't exist
pass
if self.connection is not None:
_warnings.warn(
f"Unclosed client session {self!r}",
ResourceWarning,
source=self,
)
context = {"client": self, "message": self._DEL_MESSAGE}
asyncio.get_event_loop().call_exception_handler(context)

async def close(self):
conn = self.connection
Expand Down

0 comments on commit a121f9a

Please sign in to comment.