Fixed regression in the asyncpg dialect caused by :ticket:`10717` in
release 2.0.24 where the change that now attempts to gracefully close the
asyncpg connection before terminating would not fall back to
``terminate()`` for other potential connection-related exceptions other
than a timeout error, not taking into account cases where the graceful
``.close()`` attempt fails for other reasons such as connection errors.
Fixes: #10863
Change-Id: If1791bce26803f92547cdf26fb641996c7f638fa
--- /dev/null
+.. change::
+ :tags: bug, regression, postgresql
+ :tickets: 10863
+
+ Fixed regression in the asyncpg dialect caused by :ticket:`10717` in
+ release 2.0.24 where the change that now attempts to gracefully close the
+ asyncpg connection before terminating would not fall back to
+ ``terminate()`` for other potential connection-related exceptions other
+ than a timeout error, not taking into account cases where the graceful
+ ``.close()`` attempt fails for other reasons such as connection errors.
+
# try to gracefully close; see #10717
# timeout added in asyncpg 0.14.0 December 2017
await_(self._connection.close(timeout=2))
- except asyncio.TimeoutError:
+ except (asyncio.TimeoutError, OSError, self.dbapi.PostgresError):
# in the case where we are recycling an old connection
# that may have already been disconnected, close() will
# fail with the above timeout. in this case, terminate