diff --git a/homeassistant/util/executor.py b/homeassistant/util/executor.py index 6765fc5d8ae..c25c6b9c13f 100644 --- a/homeassistant/util/executor.py +++ b/homeassistant/util/executor.py @@ -2,6 +2,7 @@ from __future__ import annotations from concurrent.futures import ThreadPoolExecutor +import contextlib import logging import queue import sys @@ -49,7 +50,11 @@ def join_or_interrupt_threads( if log: _log_thread_running_at_shutdown(thread.name, thread.ident) - async_raise(thread.ident, SystemExit) + with contextlib.suppress(SystemError): + # SystemError at this stage is usually a race condition + # where the thread happens to die right before we force + # it to raise the exception + async_raise(thread.ident, SystemExit) return joined