From 271b71e8d07e719529cf931d0f3f9563af70b911 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 15 Sep 2022 18:54:31 -0400 Subject: [PATCH] use get_event_loop() for python 3.6 per https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop the get_event_loop method will eventually be an alias for get_running_loop. the latter is not present in python 3.6 Fixes: #8516 Change-Id: Idc9ba0ca5030e7f5878d31a9ab5b5cc5d40f98b9 --- lib/sqlalchemy/ext/asyncio/engine.py | 4 ++-- lib/sqlalchemy/ext/asyncio/session.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sqlalchemy/ext/asyncio/engine.py b/lib/sqlalchemy/ext/asyncio/engine.py index ba4dd39b6f..94e54dc65e 100644 --- a/lib/sqlalchemy/ext/asyncio/engine.py +++ b/lib/sqlalchemy/ext/asyncio/engine.py @@ -551,7 +551,7 @@ class AsyncConnection(ProxyComparable, StartableContext, AsyncConnectable): return self.start().__await__() async def __aexit__(self, type_, value, traceback): - task = asyncio.get_running_loop().create_task(self.close()) + task = asyncio.get_event_loop().create_task(self.close()) await asyncio.shield(task) @@ -607,7 +607,7 @@ class AsyncEngine(ProxyComparable, AsyncConnectable): await self.transaction.__aexit__(type_, value, traceback) await self.conn.close() - task = asyncio.get_running_loop().create_task(go()) + task = asyncio.get_event_loop().create_task(go()) await asyncio.shield(task) def __init__(self, sync_engine): diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py index 61874378dd..d167ec0e98 100644 --- a/lib/sqlalchemy/ext/asyncio/session.py +++ b/lib/sqlalchemy/ext/asyncio/session.py @@ -627,7 +627,7 @@ class AsyncSession(ReversibleProxy): return self async def __aexit__(self, type_, value, traceback): - task = asyncio.get_running_loop().create_task(self.close()) + task = asyncio.get_event_loop().create_task(self.close()) await asyncio.shield(task) def _maker_context_manager(self): @@ -649,7 +649,7 @@ class _AsyncSessionContextManager: await self.trans.__aexit__(type_, value, traceback) await self.async_session.__aexit__(type_, value, traceback) - task = asyncio.get_running_loop().create_task(go()) + task = asyncio.get_event_loop().create_task(go()) await asyncio.shield(task) -- 2.47.2