summaryrefslogtreecommitdiff
path: root/Python/import.c
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-11-18 14:06:54 +0200
committerEzio Melotti <ezio.melotti@gmail.com>2012-11-18 14:06:54 +0200
commit23e41c9686435a8a01da7fead079c783087ee5c5 (patch)
tree0593cf00b74bcabb8cb52c2108750c2f80fa2c81 /Python/import.c
parent68a2b84e68c3fe3abaa1bae589e17bfbb13461c2 (diff)
parente93555d91c4608e06e3058a42af0f2450c9dfd19 (diff)
downloadcpython-23e41c9686435a8a01da7fead079c783087ee5c5.tar.gz
#16306: merge with 3.3.
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index 2f71b97bc8..6882b57060 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 {