]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
try to gracefully close even in terminate
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 30 Nov 2023 14:11:25 +0000 (09:11 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 30 Nov 2023 20:08:41 +0000 (15:08 -0500)
commit3aaa69118c0b90ae3892cb507ad97677573466c5
treed0e30ce5b0cf42ae8d429ec488bc73e486a52025
parente5b07fa0d0733d58f2ccae76fa5e4b2209129c95
try to gracefully close even in terminate

Adjusted the asyncpg dialect such that when the ``terminate()`` method is
used to discard an invalidated connection, the dialect will first attempt
to gracefully close the conneciton using ``.close()`` with a timeout, if
the operation is proceeding within an async event loop context only. This
allows the asyncpg driver to attend to finalizing a ``TimeoutError``
including being able to close a long-running query server side, which
otherwise can keep running after the program has exited.

Fixes: #10717
Change-Id: Iaba0aeb67873a7a2b3981d43f4eb663005057309
(cherry picked from commit e70a0b0a0e52945e5b588b5cffec619a3f3e78a1)
doc/build/changelog/unreleased_20/10717.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/asyncpg.py
lib/sqlalchemy/util/_concurrency_py3k.py
lib/sqlalchemy/util/concurrency.py