From f4a2afeb375483f952a0e142fb6c4ef2a7b4d21a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 16 May 2022 17:48:14 -0500 Subject: [PATCH] Guard against recorder pool current connection disappearing during global destruction (#71971) --- homeassistant/components/recorder/pool.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/recorder/pool.py b/homeassistant/components/recorder/pool.py index f2f952121af..52b6b74dfa1 100644 --- a/homeassistant/components/recorder/pool.py +++ b/homeassistant/components/recorder/pool.py @@ -55,7 +55,12 @@ class RecorderPool(SingletonThreadPool, NullPool): # type: ignore[misc] def shutdown(self) -> None: """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() def dispose(self) -> None: