diff options
| author | Mark Dickinson <mdickinson@enthought.com> | 2012-11-25 14:37:43 +0000 |
|---|---|---|
| committer | Mark Dickinson <mdickinson@enthought.com> | 2012-11-25 14:37:43 +0000 |
| commit | cb878352fec4111a2b5490e12d2df9c4cae45579 (patch) | |
| tree | a2d21729b4a3870889cfcd56a571efa0aa1572dd /Python/import.c | |
| parent | 5cd62b7fe17e8004a4f137cf9164e4e71bb1bd70 (diff) | |
| parent | 9770925980a2c52aadd6aa1a6f3c243f9a62bae9 (diff) | |
| download | cpython-cb878352fec4111a2b5490e12d2df9c4cae45579.tar.gz | |
Issue #16546: merge fix from 3.3
Diffstat (limited to 'Python/import.c')
| -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 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 { |
