summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/asyncio/session.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/ext/asyncio/session.py')
-rw-r--r--lib/sqlalchemy/ext/asyncio/session.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py
index d4b6b6d50..60b77f3ea 100644
--- a/lib/sqlalchemy/ext/asyncio/session.py
+++ b/lib/sqlalchemy/ext/asyncio/session.py
@@ -851,7 +851,8 @@ class AsyncSession(ReversibleProxy[Session]):
return self
async def __aexit__(self, type_: Any, value: Any, traceback: Any) -> None:
- await asyncio.shield(self.close())
+ task = asyncio.create_task(self.close())
+ await asyncio.shield(task)
def _maker_context_manager(self: _AS) -> _AsyncSessionContextManager[_AS]:
return _AsyncSessionContextManager(self)
@@ -1516,7 +1517,8 @@ class _AsyncSessionContextManager(Generic[_AS]):
await self.trans.__aexit__(type_, value, traceback)
await self.async_session.__aexit__(type_, value, traceback)
- await asyncio.shield(go())
+ task = asyncio.create_task(go())
+ await asyncio.shield(task)
class AsyncSessionTransaction(