Skip to content

Commit 9eb87f4

Browse files
CaselITzzzeek
authored andcommitted
asyncpg: shield connection close in terminate to avoid connection leak
Added an additional ``shield()`` call within the connection terminate process of the asyncpg driver, to mitigate an issue where terminate would be prevented from completing under the anyio concurrency library. Fixes #12077 Closes: #12076 Pull-request: #12076 Pull-request-sha: 6ae261e Change-Id: Iaec63d02b620201dc60ffdad76ba9d61d427cac1 (cherry picked from commit 2f6ca65)
1 parent 0c6ab45 commit 9eb87f4

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. change::
2+
:tags: postgresql, usecase, asyncio
3+
:tickets: 12077
4+
5+
Added an additional ``shield()`` call within the connection terminate
6+
process of the asyncpg driver, to mitigate an issue where terminate would
7+
be prevented from completing under the anyio concurrency library.

‎lib/sqlalchemy/dialects/postgresql/asyncpg.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ def terminate(self):
904904
try:
905905
# try to gracefully close; see #10717
906906
# timeout added in asyncpg 0.14.0 December 2017
907-
self.await_(self._connection.close(timeout=2))
907+
self.await_(asyncio.shield(self._connection.close(timeout=2)))
908908
except (
909909
asyncio.TimeoutError,
910910
asyncio.CancelledError,

0 commit comments

Comments
 (0)