Guard against recorder pool current connection disappearing during global destruction (#71971)

This commit is contained in:
J. Nick Koston 2022-05-16 17:48:14 -05:00 committed by GitHub
parent 007c6d2236
commit f4a2afeb37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,7 +55,12 @@ class RecorderPool(SingletonThreadPool, NullPool): # type: ignore[misc]
def shutdown(self) -> None: def shutdown(self) -> None:
"""Close the connection.""" """Close the connection."""
if self.recorder_or_dbworker and self._conn and (conn := self._conn.current()): if (
self.recorder_or_dbworker
and self._conn
and hasattr(self._conn, "current")
and (conn := self._conn.current())
):
conn.close() conn.close()
def dispose(self) -> None: def dispose(self) -> None: