mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #9573: os.fork now works when triggered as a side effect of import (the wisdom of actually relying on this remains questionable!)
This commit is contained in:
parent
d2bb830edc
commit
b2ddf7979d
3 changed files with 57 additions and 5 deletions
|
@ -325,8 +325,17 @@ _PyImport_ReInitLock(void)
|
|||
{
|
||||
if (import_lock != NULL)
|
||||
import_lock = PyThread_allocate_lock();
|
||||
import_lock_thread = -1;
|
||||
import_lock_level = 0;
|
||||
if (import_lock_level > 1) {
|
||||
/* Forked as a side effect of import */
|
||||
long me = PyThread_get_thread_ident();
|
||||
PyThread_acquire_lock(import_lock, 0);
|
||||
/* XXX: can the previous line fail? */
|
||||
import_lock_thread = me;
|
||||
import_lock_level--;
|
||||
} else {
|
||||
import_lock_thread = -1;
|
||||
import_lock_level = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue