Skip to content

Commit f6be5ad

Browse files
Harden async transport destructor loop handling
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent a8dcf47 commit f6be5ad

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

hyperbrowser/transport/async_transport.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
3333
def __del__(self):
3434
if not self._closed:
3535
try:
36-
loop = asyncio.get_event_loop()
37-
if loop.is_running():
38-
loop.create_task(self.client.aclose())
39-
else:
40-
loop.run_until_complete(self.client.aclose())
36+
loop = asyncio.get_running_loop()
37+
loop.create_task(self.client.aclose())
4138
except Exception:
4239
pass
4340

0 commit comments

Comments
 (0)