From c4006ddd20e60a0139ec1c87830f0bd1125a7fef Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 18 Sep 2021 09:47:34 -0400 Subject: [PATCH] pin asyncmy>=0.2.0 and remove cursor close workarounds Change-Id: I9426e09e4fd21f9c94f3c89b199a7784d33b949f --- lib/sqlalchemy/dialects/mysql/asyncmy.py | 22 ++++------------------ setup.cfg | 2 +- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/lib/sqlalchemy/dialects/mysql/asyncmy.py b/lib/sqlalchemy/dialects/mysql/asyncmy.py index cde43398d2..badf6e389b 100644 --- a/lib/sqlalchemy/dialects/mysql/asyncmy.py +++ b/lib/sqlalchemy/dialects/mysql/asyncmy.py @@ -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() diff --git a/setup.cfg b/setup.cfg index 8512e7abc0..6bc2596aed 100644 --- 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" -- 2.47.2