suppress_thread_exceptions doesn't fail under Python 3.6.

It uses threading.excepthook, which doesn't exist in pre-3.8 Python. But there's no need to break all the tests under 3.6.

suppress_thread_exceptions was introduced in commit 001698cd.
status-serialisers
Marnanel Thurman 2020-08-24 19:16:03 +01:00
rodzic a6e80e1de6
commit 0ab9fecea4
1 zmienionych plików z 21 dodań i 5 usunięć

Wyświetl plik

@ -7,9 +7,25 @@ def suppress_thread_exceptions():
Context manager which causes exceptions in threads not to
be printed. See https://stackoverflow.com/questions/63206653/ .
"""
orig = threading.excepthook
threading.excepthook = lambda a: None
try:
yield
finally:
threading.excepthook = orig
orig = threading.excepthook
threading.excepthook = lambda a: None
try:
yield
finally:
threading.excepthook = orig
except AttributeError:
# Python 3.6 doesn't have threading.excepthook,
# but everything else in kepi works. So if it's
# missing, we work around that.
print("""Warning:
You are running a version of Python without threading.excepthook.
You will see spurious error messages during testing.
""")
try:
yield
finally:
pass