]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
pin asyncmy>=0.2.0 and remove cursor close workarounds
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 18 Sep 2021 13:47:34 +0000 (09:47 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 18 Sep 2021 13:47:34 +0000 (09:47 -0400)
Change-Id: I9426e09e4fd21f9c94f3c89b199a7784d33b949f

lib/sqlalchemy/dialects/mysql/asyncmy.py
setup.cfg

index cde43398d2ae8c475dcf35711a0d1462cde810e7..badf6e389b4185adb186123d0fc727b06f374165 100644 (file)
@@ -150,8 +150,6 @@ class AsyncAdapt_asyncmy_ss_cursor(AsyncAdapt_asyncmy_cursor):
         self._connection = adapt_connection._connection
         self.await_ = adapt_connection.await_
 
-        adapt_connection._ss_cursors.add(self)
-
         cursor = self._connection.cursor(
             adapt_connection.dbapi.asyncmy.cursors.SSCursor
         )
@@ -159,13 +157,9 @@ class AsyncAdapt_asyncmy_ss_cursor(AsyncAdapt_asyncmy_cursor):
         self._cursor = self.await_(cursor.__aenter__())
 
     def close(self):
-        try:
-            if self._cursor is not None:
-                self.await_(self._cursor.fetchall())
-                self.await_(self._cursor.close())
-                self._cursor = None
-        finally:
-            self._adapt_connection._ss_cursors.discard(self)
+        if self._cursor is not None:
+            self.await_(self._cursor.close())
+            self._cursor = None
 
     def fetchone(self):
         return self.await_(self._cursor.fetchone())
@@ -179,13 +173,12 @@ class AsyncAdapt_asyncmy_ss_cursor(AsyncAdapt_asyncmy_cursor):
 
 class AsyncAdapt_asyncmy_connection:
     await_ = staticmethod(await_only)
-    __slots__ = ("dbapi", "_connection", "_execute_mutex", "_ss_cursors")
+    __slots__ = ("dbapi", "_connection", "_execute_mutex")
 
     def __init__(self, dbapi, connection):
         self.dbapi = dbapi
         self._connection = connection
         self._execute_mutex = asyncio.Lock()
-        self._ss_cursors = set()
 
     @asynccontextmanager
     async def _mutex_and_adapt_errors(self):
@@ -217,20 +210,13 @@ class AsyncAdapt_asyncmy_connection:
         else:
             return AsyncAdapt_asyncmy_cursor(self)
 
-    def _shutdown_ss_cursors(self):
-        for curs in list(self._ss_cursors):
-            curs.close()
-
     def rollback(self):
-        self._shutdown_ss_cursors()
         self.await_(self._connection.rollback())
 
     def commit(self):
-        self._shutdown_ss_cursors()
         self.await_(self._connection.commit())
 
     def close(self):
-        self._shutdown_ss_cursors()
         # it's not awaitable.
         self._connection.close()
 
index 8512e7abc07523d4b169444e76dabb3929328124..6bc2596aed55c4f75ef30d0f76b4743807438c75 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -76,7 +76,7 @@ aiomysql =
     aiomysql;python_version>="3"
 asyncmy =
     %(asyncio)s
-    asyncmy;python_version>="3"
+    asyncmy>=0.2.0;python_version>="3"
 aiosqlite =
     %(asyncio)s
     aiosqlite;python_version>="3"