]> granicus.if.org Git - python/commit
Add a single Python-wide (!) lock on import. Only one thread at a
authorGuido van Rossum <guido@python.org>
Tue, 3 Mar 1998 22:26:50 +0000 (22:26 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 3 Mar 1998 22:26:50 +0000 (22:26 +0000)
commit75acc9ca1c2415717951ac11347714563894b325
treefa149a3c9fa6a1b26cfa2f3382a4676122ab4475
parent78535706517b3e6bf0c2e594e3c53dbed10c016e
Add a single Python-wide (!) lock on import.  Only one thread at a
time can be in PyImport_ImportModuleEx().  Recursive calls from the
same thread are okay.

Potential problems:

- The lock should really be part of the interpreter state rather than
global, but that would require modifying more files, and I first want
to figure out whether this works at all.

- One could argue that the lock should be per module -- however that
would be complicated to implement.  We would have to have a linked
list of locks per module name, *or* invent a new object type to
represent a lock, so we can store the locks in the module or in a
separate dictionary.  Both seem unwarranted.  The one situation where
this can cause problems is when loading a module takes a long time,
e.g. when the module's initialization code interacts with the user --
during that time, no other threads can run.  I say, "too bad."
Python/import.c