Skip to content

Commit 45b34a0

Browse files
authored
bpo-40232: _PyImport_ReInitLock() can now safely use its lock (GH-20597)
Since _PyImport_ReInitLock() now calls _PyThread_at_fork_reinit() on the import lock, the lock is now in a known state: unlocked. It became safe to acquire it after fork.
1 parent 26881c8 commit 45b34a0

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Python/import.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,7 @@ _PyImport_ReInitLock(void)
213213
if (import_lock_level > 1) {
214214
/* Forked as a side effect of import */
215215
unsigned long me = PyThread_get_thread_ident();
216-
/* The following could fail if the lock is already held, but forking as
217-
a side-effect of an import is a) rare, b) nuts, and c) difficult to
218-
do thanks to the lock only being held when doing individual module
219-
locks per import. */
220-
PyThread_acquire_lock(import_lock, NOWAIT_LOCK);
216+
PyThread_acquire_lock(import_lock, WAIT_LOCK);
221217
import_lock_thread = me;
222218
import_lock_level--;
223219
} else {

0 commit comments

Comments
 (0)