mirror of
https://github.com/python/cpython.git
synced 2025-08-15 06:10:47 +00:00
[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
)
This commit is contained in:
parent
75239d5ec1
commit
33d3069c45
17 changed files with 1342 additions and 689 deletions
|
@ -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))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue