This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author David.Edelsohn
Recipients David.Edelsohn, Michael.Felt, shihai1991, vstinner
Date 2021-05-24.20:16:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
It seems that PyOS_AfterFork_Child() needs to do something like

PyThreadState *tstate = PyThreadState_Get();
PyObject *wr = _PyObject_CAST(tstate->on_delete_data);
PyObject *obj = PyWeakref_GET_OBJECT(wr);
lockobject *lock;
if (obj != Py_None) {
    lock = (lockobject *) obj;
    if (lock->locked) {
        /* Leak memory on purpose. */
        lock->locked = 0;

before the call to _PyEval_ReInitThreads.

Maybe encapsulate that as PyThread_ReInitThreads().

The locks in the threads in the child need to be cleared before _PyThreadState_DeleteExcept() so that Python does not try to release the locks in the child.
Date User Action Args
2021-05-24 20:16:41David.Edelsohnsetrecipients: + David.Edelsohn, vstinner, Michael.Felt, shihai1991
2021-05-24 20:16:41David.Edelsohnsetmessageid: <>
2021-05-24 20:16:41David.Edelsohnlinkissue40092 messages
2021-05-24 20:16:41David.Edelsohncreate