mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Handle threads exiting unexpected during shutdown (#50907)
If a thread exits right when we are trying to force an exception to shut it down, setting the exception will fail with SystemError. At this point in the shutdown process we want to move on as this will cause the shutdown to abort
This commit is contained in:
parent
0623648309
commit
eddc1ab778
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user