]> 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:36:37 +0000 (11:36 -0400)
commit6d0570de2b43463b82fbf6628610bf3c89befd59
tree4275bb59c98f31149ca3cea6b1fcfc1777faee5b
parent0052827c44e9124e89cb3ba5b922b786fe333c9e
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
(cherry picked from commit 1acaf0b2e4859a274e753b5054dcde3d5c7ca10e)
doc/build/changelog/unreleased_14/8145.rst [new file with mode: 0644]
lib/sqlalchemy/ext/asyncio/engine.py
lib/sqlalchemy/ext/asyncio/session.py