diff options
author | Brett Cannon <brett@python.org> | 2012-11-16 02:39:36 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-11-16 02:39:36 (GMT) |
commit | e4710cfcedbecbd3bfa154c2586415ab5b6e28bc (patch) | |
tree | 0e8da2fa36596ed887e78771d765ddedc615b1ea /Python | |
parent | 1e1e8aa5074ae43c757764f3ba3bce1efc765346 (diff) | |
download | cpython-e4710cfcedbecbd3bfa154c2586415ab5b6e28bc.zip cpython-e4710cfcedbecbd3bfa154c2586415ab5b6e28bc.tar.gz cpython-e4710cfcedbecbd3bfa154c2586415ab5b6e28bc.tar.bz2 |
Issue #15894: Document why we don't worry about re-acquiring the
global import lock after forking.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c index 2f71b97..6882b57 100644 --- a/Python/import.c +++ b/Python/import.c @@ -202,8 +202,11 @@ _PyImport_ReInitLock(void) 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? */ + /* The following could fail if the lock is already held, but forking as + 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_level--; } else { |