mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-126688: Reinit import lock after fork (#126692)
The PyMutex implementation supports unlocking after fork because we clear the list of waiters in parking_lot.c. This doesn't work as well for _PyRecursiveMutex because on some systems, such as SerenityOS, the thread id is not preserved across fork().
This commit is contained in:
parent
bf224bd7ce
commit
5610860840
4 changed files with 11 additions and 0 deletions
|
@ -122,6 +122,13 @@ _PyImport_ReleaseLock(PyInterpreterState *interp)
|
|||
_PyRecursiveMutex_Unlock(&IMPORT_LOCK(interp));
|
||||
}
|
||||
|
||||
void
|
||||
_PyImport_ReInitLock(PyInterpreterState *interp)
|
||||
{
|
||||
// gh-126688: Thread id may change after fork() on some operating systems.
|
||||
IMPORT_LOCK(interp).thread = PyThread_get_thread_ident_ex();
|
||||
}
|
||||
|
||||
|
||||
/***************/
|
||||
/* sys.modules */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue