Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1e1e8aa commit e4710cfCopy full SHA for e4710cf
1 file changed
Python/import.c
@@ -202,8 +202,11 @@ _PyImport_ReInitLock(void)
202
if (import_lock_level > 1) {
203
/* Forked as a side effect of import */
204
long me = PyThread_get_thread_ident();
205
- PyThread_acquire_lock(import_lock, 0);
206
- /* 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
207
+ do thanks to the lock only being held when doing individual module
208
+ locks per import. */
209
+ PyThread_acquire_lock(import_lock, NOWAIT_LOCK);
210
import_lock_thread = me;
211
import_lock_level--;
212
} else {
0 commit comments