]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
use get_event_loop() for python 3.6
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 15 Sep 2022 22:54:31 +0000 (18:54 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 15 Sep 2022 22:55:31 +0000 (18:55 -0400)
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
lib/sqlalchemy/ext/asyncio/session.py

index ba4dd39b6f29f9a49561b46caea900728fd4f3bb..94e54dc65e8f357debc181cc895474ec02c93f5f 100644 (file)
@@ -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):
index 61874378dd09c67edbd50897ebf5f1192eb70a94..d167ec0e98011e3b3b97d92c20f60a04f3ac46dc 100644 (file)
@@ -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)