summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/threading_helper.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-06-14 00:50:08 (GMT)
committerGitHub <noreply@github.com>2023-06-14 00:50:08 (GMT)
commit33d3069c45bda38f52053a115e3c0810cd631dd6 (patch)
treeee49a043f3960473e891ce9a1a4be3abee2a878c /Lib/test/support/threading_helper.py
parent75239d5ec1505b8f9f20d3c2d366c1a3ebd269aa (diff)
downloadcpython-33d3069c45bda38f52053a115e3c0810cd631dd6.zip
cpython-33d3069c45bda38f52053a115e3c0810cd631dd6.tar.gz
cpython-33d3069c45bda38f52053a115e3c0810cd631dd6.tar.bz2
[3.12] gh-104812: Run Pending Calls in any Thread (gh-104813) (gh-105752)
For a while now, pending calls only run in the main thread (in the main interpreter). This PR changes things to allow any thread run a pending call, unless the pending call was explicitly added for the main thread to run. (cherry picked from commit 757b402)
Diffstat (limited to 'Lib/test/support/threading_helper.py')
-rw-r--r--Lib/test/support/threading_helper.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/support/threading_helper.py b/Lib/test/support/threading_helper.py
index b9973c8..7f16050 100644
--- a/Lib/test/support/threading_helper.py
+++ b/Lib/test/support/threading_helper.py
@@ -115,7 +115,11 @@ def join_thread(thread, timeout=None):
@contextlib.contextmanager
def start_threads(threads, unlock=None):
- import faulthandler
+ try:
+ import faulthandler
+ except ImportError:
+ # It isn't supported on subinterpreters yet.
+ faulthandler = None
threads = list(threads)
started = []
try:
@@ -147,7 +151,8 @@ def start_threads(threads, unlock=None):
finally:
started = [t for t in started if t.is_alive()]
if started:
- faulthandler.dump_traceback(sys.stdout)
+ if faulthandler is not None:
+ faulthandler.dump_traceback(sys.stdout)
raise AssertionError('Unable to join %d threads' % len(started))