mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #15894: Document why we don't worry about re-acquiring the
global import lock after forking.
This commit is contained in:
parent
1e1e8aa507
commit
e4710cfced
1 changed files with 5 additions and 2 deletions
|
@ -202,8 +202,11 @@ _PyImport_ReInitLock(void)
|
||||||
if (import_lock_level > 1) {
|
if (import_lock_level > 1) {
|
||||||
/* Forked as a side effect of import */
|
/* Forked as a side effect of import */
|
||||||
long me = PyThread_get_thread_ident();
|
long me = PyThread_get_thread_ident();
|
||||||
PyThread_acquire_lock(import_lock, 0);
|
/* The following could fail if the lock is already held, but forking as
|
||||||
/* XXX: can the previous line fail? */
|
a side-effect of an import is a) rare, b) nuts, and c) difficult to
|
||||||
|
do thanks to the lock only being held when doing individual module
|
||||||
|
locks per import. */
|
||||||
|
PyThread_acquire_lock(import_lock, NOWAIT_LOCK);
|
||||||
import_lock_thread = me;
|
import_lock_thread = me;
|
||||||
import_lock_level--;
|
import_lock_level--;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue