Issue 36728: Remove PyEval_ReInitThreads() from the public C API (original) (raw)

Created on 2019-04-25 23:22 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13241 merged vstinner,2019-05-11 01:57
PR 13282 merged vstinner,2019-05-13 13:57
Messages (6)
msg340868 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-25 23:22
PyEval_ReInitThreads() is used internally by PyOS_AfterFork_Child(). I don't see the point of calling it directly. If you care of threads after fork, just call PyOS_AfterFork_Child(), no? I propose to remove PyEval_ReInitThreads() from the public C API. Problem: it's documented as a public function in High-level API of the Python Initialization API: https://docs.python.org/dev/c-api/init.html#c.PyEval_ReInitThreads On the Internet, I found a single project calling directly this function, but it's only in a test used to the test Python threading API: https://github.com/DataDog/go-python3/blob/master/thread_test.go func TestThreadInitialization(t *testing.T) { Py_Initialize() PyEval_InitThreads() assert.True(t, PyEval_ThreadsInitialized()) PyEval_ReInitThreads() } I don't think that the PyEval_ReInitThreads() call here makes any sense.
msg342147 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-11 01:58
The function was added 19 years ago: commit fee3a2dd8cf984b8261032086fe513bf7327b601 Author: Guido van Rossum <guido@python.org> Date: Sun Aug 27 17:34:07 2000 +0000 Charles Waldman's patch to reinitialize the interpreter lock after a fork. This solves the test_fork1 problem. (ceval.c, signalmodule.c, intrcheck.c) SourceForge: [ Patch #101226 ] make threading fork-safe
msg342279 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2019-05-13 02:18
fwiw - i agree that this can be removed. it has no reason to ever be called directly. i double checked in our massive internal codebase at work and found no calls other than python interpreters themselves.
msg342291 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-13 09:07
> i double checked in our massive internal codebase at work and found no calls other than python interpreters themselves. Thanks. It confirms what I understood using GitHub code search (see my initial message).
msg342306 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-13 10:35
New changeset d5d9e81ce9a7efc5bc14a5c21398d1ef6f626884 by Victor Stinner in branch 'master': bpo-36728: Remove PyEval_ReInitThreads() from C API (GH-13241) https://github.com/python/cpython/commit/d5d9e81ce9a7efc5bc14a5c21398d1ef6f626884
msg342333 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-13 14:22
New changeset c1f7262f7013074613805347db2276f8b5e0e3a4 by Victor Stinner in branch 'master': bpo-36728: Remove PyEval_ReInitThreads documentation (GH-13282) https://github.com/python/cpython/commit/c1f7262f7013074613805347db2276f8b5e0e3a4
History
Date User Action Args
2022-04-11 14:59:14 admin set github: 80909
2019-05-13 14:22:56 vstinner set messages: +
2019-05-13 13:57:14 vstinner set pull_requests: + <pull%5Frequest13189>
2019-05-13 10:35:55 vstinner set status: open -> closedresolution: fixedstage: patch review -> resolved
2019-05-13 10:35:42 vstinner set messages: +
2019-05-13 09:07:38 vstinner set messages: +
2019-05-13 02🔞54 gregory.p.smith set nosy: + gregory.p.smithmessages: +
2019-05-11 01:58:38 vstinner set messages: +
2019-05-11 01:57:21 vstinner set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest13151>
2019-04-25 23:22:09 vstinner create