]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
close aio cursors etc. that require await close rel_2_0
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 12 Aug 2025 19:25:15 +0000 (15:25 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 13 Aug 2025 03:00:58 +0000 (23:00 -0400)
commitbfdfe6a295fc826493c18f534cae4d52dd322cdc
tree99f540c203ec2708b8e4823fd1d2c1b52da7ae3a
parentbdaf414657a366f4c994b7cf7d1744b81ce66b9a
close aio cursors etc. that require await close

Improved the base implementation of the asyncio cursor such that it
includes the option for the underlying driver's cursor to be actively
closed in those cases where it requires ``await`` in order to complete the
close sequence, rather than relying on garbage collection to "close" it,
when a plain :class:`.Result` is returned that does not use ``await`` for
any of its methods.  The previous approach of relying on gc was fine for
MySQL and SQLite dialects but has caused problems with the aioodbc
implementation on top of SQL Server.   The new option is enabled
for those dialects which have an "awaitable" ``cursor.close()``, which
includes the aioodbc, aiomysql, and asyncmy dialects (aiosqlite is also
modified for 2.1 only).

Fixes: #12798
Change-Id: Ib17d611201fedf9780dfe3d760760ace99a8835c
(cherry picked from commit 5dbb5ec0e4ce71f7b806b87808a504083a7e8ffa)
doc/build/changelog/unreleased_20/12798.rst [new file with mode: 0644]
lib/sqlalchemy/connectors/asyncio.py
lib/sqlalchemy/dialects/oracle/oracledb.py
lib/sqlalchemy/dialects/postgresql/asyncpg.py
lib/sqlalchemy/dialects/postgresql/psycopg.py
lib/sqlalchemy/dialects/sqlite/aiosqlite.py
lib/sqlalchemy/ext/asyncio/result.py
test/ext/asyncio/test_engine_py3k.py
test/requirements.py