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: https://github.com/sqlalchemy/sqlalchemy/pull/12076
Pull-request-sha:
6ae261ea7668f4c850874666efec6fef658b08c0
Change-Id: Iaec63d02b620201dc60ffdad76ba9d61d427cac1
(cherry picked from commit
2f6ca6554ddd725849dd6b2d32bf495391087bec)
--- /dev/null
+.. change::
+ :tags: postgresql, usecase, asyncio
+ :tickets: 12077
+
+ 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.
try:
# try to gracefully close; see #10717
# timeout added in asyncpg 0.14.0 December 2017
- self.await_(self._connection.close(timeout=2))
+ self.await_(asyncio.shield(self._connection.close(timeout=2)))
except (
asyncio.TimeoutError,
asyncio.CancelledError,