[Python-checkins] gh-100649: Update native_thread_id after fork (gh-100650)

miss-islington webhook-mailer at python.org
Sun Jan 1 09:51:01 EST 2023


https://github.com/python/cpython/commit/d0a9bc5a89728a66f66835cbeec6a33aa7de26f0
commit: d0a9bc5a89728a66f66835cbeec6a33aa7de26f0
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2023-01-01T06:50:56-08:00
summary:

gh-100649: Update native_thread_id after fork (gh-100650)


Update native_thread_id after fork
(cherry picked from commit d52d4942cfdd52a50f88b87b1ff2a67375dbcf47)

Co-authored-by: Gabriele N. Tornetta <P403n1x87 at users.noreply.github.com>

files:
A Misc/NEWS.d/next/Core and Builtins/2022-12-31-23-32-09.gh-issue-100649.C0fY4S.rst
M Modules/posixmodule.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-12-31-23-32-09.gh-issue-100649.C0fY4S.rst b/Misc/NEWS.d/next/Core and Builtins/2022-12-31-23-32-09.gh-issue-100649.C0fY4S.rst
new file mode 100644
index 000000000000..7ee929ad09fb
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-12-31-23-32-09.gh-issue-100649.C0fY4S.rst	
@@ -0,0 +1 @@
+Update the native_thread_id field of PyThreadState after fork.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 2dfed7c583c4..150bb78cb41c 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -591,6 +591,10 @@ PyOS_AfterFork_Child(void)
     PyThreadState *tstate = _PyThreadState_GET();
     _Py_EnsureTstateNotNULL(tstate);
 
+#ifdef PY_HAVE_THREAD_NATIVE_ID
+    tstate->native_thread_id = PyThread_get_thread_native_id();
+#endif
+
     status = _PyEval_ReInitThreads(tstate);
     if (_PyStatus_EXCEPTION(status)) {
         goto fatal_error;



More information about the Python-checkins mailing list