Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion aiomysql/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,10 @@ async def __aenter__(self):

async def __aexit__(self, exc_type, exc_val, exc_tb):
self.close()
await self.wait_closed()
try:
await self.wait_closed()
except RuntimeError as e:
if "Event loop is closed" in str(e):
# Gracefully handle event loop shutdown during asyncio.run()
return
raise
8 changes: 7 additions & 1 deletion aiomysql/sa/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,13 @@ async def __aenter__(self):

async def __aexit__(self, exc_type, exc_val, exc_tb):
self.close()
await self.wait_closed()
try:
await self.wait_closed()
except RuntimeError as e:
if "Event loop is closed" in str(e):
# Gracefully handle event loop shutdown during asyncio.run()
return
raise


_EngineContextManager = _PoolContextManager
Expand Down