diff --git a/homeassistant/components/recorder/core.py b/homeassistant/components/recorder/core.py index 8706bc1c7a8..88b63e93733 100644 --- a/homeassistant/components/recorder/core.py +++ b/homeassistant/components/recorder/core.py @@ -13,6 +13,7 @@ import threading import time from typing import Any, TypeVar, cast +import async_timeout from awesomeversion import AwesomeVersion from lru import LRU # pylint: disable=no-name-in-module from sqlalchemy import create_engine, event as sqlalchemy_event, exc, func, select @@ -1030,7 +1031,8 @@ class Recorder(threading.Thread): task = DatabaseLockTask(database_locked, threading.Event(), False) self.queue_task(task) try: - await asyncio.wait_for(database_locked.wait(), timeout=DB_LOCK_TIMEOUT) + async with async_timeout.timeout(DB_LOCK_TIMEOUT): + await database_locked.wait() except asyncio.TimeoutError as err: task.database_unlock.set() raise TimeoutError(