]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
add shield() in aexit
authorFederico Caselli <cfederico87@gmail.com>
Fri, 17 Jun 2022 21:12:39 +0000 (23:12 +0200)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 18 Jul 2022 15:33:34 +0000 (11:33 -0400)
commit1acaf0b2e4859a274e753b5054dcde3d5c7ca10e
treed70c74d7b40e8afa6676c24b0f202e9d53c3df0d
parentc3102b85c40ab4578a0f56ee1e8eee4a6e0aed55
add shield() in aexit

Added ``asyncio.shield()`` to the connection and session release process
specifically within the ``__aexit__()`` context manager exit, when using
:class:`.AsyncConnection` or :class:`.AsyncSession` as a context manager
that releases the object when the context manager is complete. This appears
to help with task cancellation when using alternate concurrency libraries
such as ``anyio``, ``uvloop`` that otherwise don't provide an async context
for the connection pool to release the connection properly during task
cancellation.

Fixes: #8145
Change-Id: I0b1ea9c3a22a18619341cbb8591225fcd339042c
doc/build/changelog/unreleased_14/8145.rst [new file with mode: 0644]
lib/sqlalchemy/ext/asyncio/engine.py
lib/sqlalchemy/ext/asyncio/session.py