Fixed issue in asyncio dialects asyncmy and aiomysql, where their
``.close()`` method is apparently not a graceful close. replace with
non-standard ``.ensure_closed()`` method that's awaitable and move
``.close()`` to the so-called "terminate" case.
Fixes: #10893
Change-Id: I33d871e67854d85f770c46f699e41a6e73b6fbe0
(cherry picked from commit
4201b90210dcf60f9830df299be016dee315753b)
--- /dev/null
+.. change::
+ :tags: bug, mysql
+ :tickets: 10893
+
+ Fixed issue in asyncio dialects asyncmy and aiomysql, where their
+ ``.close()`` method is apparently not a graceful close. replace with
+ non-standard ``.ensure_closed()`` method that's awaitable and move
+ ``.close()`` to the so-called "terminate" case.
def commit(self):
self.await_(self._connection.commit())
- def close(self):
+ def terminate(self):
# it's not awaitable.
self._connection.close()
+ def close(self) -> None:
+ self.await_(self._connection.ensure_closed())
+
class AsyncAdaptFallback_aiomysql_connection(AsyncAdapt_aiomysql_connection):
# TODO: base on connectors/asyncio.py
_sscursor = AsyncAdapt_aiomysql_ss_cursor
is_async = True
+ has_terminate = True
@classmethod
def import_dbapi(cls):
else:
return pool.AsyncAdaptedQueuePool
+ def do_terminate(self, dbapi_connection) -> None:
+ dbapi_connection.terminate()
+
def create_connect_args(self, url):
return super().create_connect_args(
url, _translate_args=dict(username="user", database="db")
def commit(self):
self.await_(self._connection.commit())
- def close(self):
+ def terminate(self):
# it's not awaitable.
self._connection.close()
+ def close(self) -> None:
+ self.await_(self._connection.ensure_closed())
+
class AsyncAdaptFallback_asyncmy_connection(AsyncAdapt_asyncmy_connection):
__slots__ = ()
_sscursor = AsyncAdapt_asyncmy_ss_cursor
is_async = True
+ has_terminate = True
@classmethod
def import_dbapi(cls):
else:
return pool.AsyncAdaptedQueuePool
+ def do_terminate(self, dbapi_connection) -> None:
+ dbapi_connection.terminate()
+
def create_connect_args(self, url):
return super().create_connect_args(
url, _translate_args=dict(username="user", database="db")