--- /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 autocommit(self, value):
await_(self._connection.autocommit(value))
- def close(self):
+ def terminate(self):
# it's not awaitable.
self._connection.close()
+ def close(self) -> None:
+ await_(self._connection.ensure_closed())
+
class AsyncAdapt_aiomysql_dbapi:
def __init__(self, aiomysql, pymysql):
_sscursor = AsyncAdapt_aiomysql_ss_cursor
is_async = True
+ has_terminate = True
@classmethod
def import_dbapi(cls):
__import__("aiomysql"), __import__("pymysql")
)
+ 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 autocommit(self, value):
await_(self._connection.autocommit(value))
- def close(self):
+ def terminate(self):
# it's not awaitable.
self._connection.close()
+ def close(self) -> None:
+ await_(self._connection.ensure_closed())
+
def _Binary(x):
"""Return x as a binary type."""
_sscursor = AsyncAdapt_asyncmy_ss_cursor
is_async = True
+ has_terminate = True
@classmethod
def import_dbapi(cls):
return AsyncAdapt_asyncmy_dbapi(__import__("asyncmy"))
+ 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")