]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
close aio cursors etc. that require await close
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:02:03 +0000 (23:02 -0400)
commit2e9902a34fafff0ac6d6c521a86c7dea3d96a392
tree590cfeb967399995577725fdd0a50a064d11acbf
parentd8efe31c1c4eeaf1f3d527a10b8607276a4c4fa3
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
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/ext/asyncio/result.py
test/ext/asyncio/test_engine_py3k.py
test/requirements.py