[Python-checkins] cpython: Issue #15894: Document why we don't worry about re-acquiring the
brett.cannon
python-checkins at python.org
Fri Nov 16 03:39:51 CET 2012
http://hg.python.org/cpython/rev/bd853311ffe0
changeset: 80451:bd853311ffe0
user: Brett Cannon <brett at python.org>
date: Thu Nov 15 21:39:36 2012 -0500
summary:
Issue #15894: Document why we don't worry about re-acquiring the
global import lock after forking.
files:
Python/import.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -202,8 +202,11 @@
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 {
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list