mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-115035: Mark ThreadHandles as non-joinable earlier after forking (#115042)
This marks dead ThreadHandles as non-joinable earlier in `PyOS_AfterFork_Child()` before we execute any Python code. The handles are stored in a global linked list in `_PyRuntimeState` because `fork()` affects the entire process.
This commit is contained in:
parent
71239d50b5
commit
b6228b521b
7 changed files with 50 additions and 41 deletions
|
@ -949,7 +949,6 @@ class Thread:
|
|||
# This thread is alive.
|
||||
self._ident = new_ident
|
||||
if self._handle is not None:
|
||||
self._handle.after_fork_alive()
|
||||
assert self._handle.ident == new_ident
|
||||
# bpo-42350: If the fork happens when the thread is already stopped
|
||||
# (ex: after threading._shutdown() has been called), _tstate_lock
|
||||
|
@ -965,9 +964,7 @@ class Thread:
|
|||
self._is_stopped = True
|
||||
self._tstate_lock = None
|
||||
self._join_lock = None
|
||||
if self._handle is not None:
|
||||
self._handle.after_fork_dead()
|
||||
self._handle = None
|
||||
self._handle = None
|
||||
|
||||
def __repr__(self):
|
||||
assert self._initialized, "Thread.__init__() was not called"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue