summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-02 15:13:49 (GMT)
committerGitHub <noreply@github.com>2020-06-02 15:13:49 (GMT)
commit45b34a04a577aa49fa4825421758c3e8eaa1625d (patch)
tree3c6742d0d91b449447e32b5b75dbc884323cda50 /Python
parent26881c8fae3b67db3a01d335d3ae7356a29b433e (diff)
downloadcpython-45b34a04a577aa49fa4825421758c3e8eaa1625d.zip
cpython-45b34a04a577aa49fa4825421758c3e8eaa1625d.tar.gz
cpython-45b34a04a577aa49fa4825421758c3e8eaa1625d.tar.bz2
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.
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/Python/import.c b/Python/import.c
index 35724fe..5056884 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -213,11 +213,7 @@ _PyImport_ReInitLock(void)
if (import_lock_level > 1) {
/* Forked as a side effect of import */
unsigned long me = PyThread_get_thread_ident();
- /* 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);
+ PyThread_acquire_lock(import_lock, WAIT_LOCK);
import_lock_thread = me;
import_lock_level--;
} else {