summaryrefslogtreecommitdiff
path: root/Python/import.c
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2012-12-13 15:21:16 +0000
committerRoss Lagerwall <rosslagerwall@gmail.com>2012-12-13 15:21:16 +0000
commit447289bc54991d2f94052a1c180cf3567c81edbc (patch)
tree02be8f2100bb1481afadf22acf496f0a9ef5ed6c /Python/import.c
parent97ed28f0985683390be4ea86e1fa01ded50d3574 (diff)
parent80527255bafedc2f5285fc1e337007d6be3263c7 (diff)
downloadcpython-447289bc54991d2f94052a1c180cf3567c81edbc.tar.gz
Merge with 3.3 for #16661
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 {