]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.11] gh-102512: Turn _DummyThread into _MainThread after os.fork() called from...
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 22 Jan 2024 15:00:33 +0000 (17:00 +0200)
committerGitHub <noreply@github.com>
Mon, 22 Jan 2024 15:00:33 +0000 (15:00 +0000)
commita0f30b04fe3a54ffe4dbd39bd927fc45a0896f2d
treee7ccf229147b50dcecdd9ddca0539477b89e56f2
parent459726f6cde7867ee33a31f9fab250dc9d421367
[3.11] gh-102512: Turn _DummyThread into _MainThread after os.fork() called from a foreign thread (GH-113261) (GH-114431)

Always set a _MainThread as a main thread after os.fork() is called from
a thread started not by the threading module.

A new _MainThread was already set as a new main thread after fork if
threading.current_thread() was not called for a foreign thread before fork.
Now, if it was called before fork, the implicitly created _DummyThread will
be turned into _MainThread after fork.

It fixes, in particularly, an incompatibility of _DummyThread with
the threading shutdown logic which relies on the main thread
having tstate_lock.

(cherry picked from commit 49785b06ded19c7c4afce186bac90fea707470ea)

Co-authored-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Lib/test/test_threading.py
Lib/threading.py
Misc/NEWS.d/next/Library/2023-03-08-00-02-30.gh-issue-102512.LiugDr.rst [new file with mode: 0644]