Drop remaining Python < 3.8 support (#44743)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
134db3f710
commit
43474762b2
17 changed files with 20 additions and 72 deletions
|
@ -1,33 +1,10 @@
|
|||
"""Threading util helpers."""
|
||||
import ctypes
|
||||
import inspect
|
||||
import sys
|
||||
import threading
|
||||
from typing import Any
|
||||
|
||||
|
||||
def fix_threading_exception_logging() -> None:
|
||||
"""Fix threads passing uncaught exceptions to our exception hook.
|
||||
|
||||
https://bugs.python.org/issue1230540
|
||||
Fixed in Python 3.8.
|
||||
"""
|
||||
if sys.version_info[:2] >= (3, 8):
|
||||
return
|
||||
|
||||
run_old = threading.Thread.run
|
||||
|
||||
def run(*args: Any, **kwargs: Any) -> None:
|
||||
try:
|
||||
run_old(*args, **kwargs)
|
||||
except (KeyboardInterrupt, SystemExit): # pylint: disable=try-except-raise
|
||||
raise
|
||||
except Exception: # pylint: disable=broad-except
|
||||
sys.excepthook(*sys.exc_info())
|
||||
|
||||
threading.Thread.run = run # type: ignore
|
||||
|
||||
|
||||
def _async_raise(tid: int, exctype: Any) -> None:
|
||||
"""Raise an exception in the threads with id tid."""
|
||||
if not inspect.isclass(exctype):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue