From: Mike Bayer Date: Mon, 2 Sep 2024 15:18:35 +0000 (-0400) Subject: add asyncio.CancelledError to terminate conditions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc7aec467487f729c3a6d1e9e352626593cf5d67;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git add asyncio.CancelledError to terminate conditions Revising the asyncpg ``terminate()`` fix first made in :ticket:`10717` which improved the resiliency of this call under all circumstances, adding ``asyncio.CancelledError`` to the list of exceptions that are intercepted as failing for a graceful ``.close()`` which will then proceed to call ``.terminate()``. Fixes: #11821 Change-Id: Ic5e21cd18cc5517aae372560c52b2b2396c65483 --- diff --git a/doc/build/changelog/unreleased_20/11821.rst b/doc/build/changelog/unreleased_20/11821.rst new file mode 100644 index 0000000000..b72412f489 --- /dev/null +++ b/doc/build/changelog/unreleased_20/11821.rst @@ -0,0 +1,9 @@ +.. change:: + :tags: bug, postgresql + :tickets: 11821 + + Revising the asyncpg ``terminate()`` fix first made in :ticket:`10717` + which improved the resiliency of this call under all circumstances, adding + ``asyncio.CancelledError`` to the list of exceptions that are intercepted + as failing for a graceful ``.close()`` which will then proceed to call + ``.terminate()``. diff --git a/lib/sqlalchemy/dialects/postgresql/asyncpg.py b/lib/sqlalchemy/dialects/postgresql/asyncpg.py index cb6b75154f..40794e1dd8 100644 --- a/lib/sqlalchemy/dialects/postgresql/asyncpg.py +++ b/lib/sqlalchemy/dialects/postgresql/asyncpg.py @@ -902,6 +902,7 @@ class AsyncAdapt_asyncpg_connection(AsyncAdapt_dbapi_connection): await_(self._connection.close(timeout=2)) except ( asyncio.TimeoutError, + asyncio.CancelledError, OSError, self.dbapi.asyncpg.PostgresError, ):