[issue8098] PyImport_ImportModuleNoBlock() may solve problems but causes others.

Antoine Pitrou report at bugs.python.org
Tue Jul 13 15:36:41 CEST 2010


Antoine Pitrou <pitrou at free.fr> added the comment:

> Pretty much anything mentioned in PEP 302 is what is being protected.

Alright, my question was more along the lines of "what *needs* to be
protected". The import lock is currently like the GIL: a very simple
(and therefore suboptimal) answer to a complex problem.

I am wondering whether one could revive Marc-André's idea here:
http://mail.python.org/pipermail/python-dev/2003-February/033445.html

If the sole purpose is to prevent multi-threaded import of the same
module, then we can have an internal dict of temporary locks for each
module being imported. The "global import lock" itself can be reduced to
protecting accesses to this dict.

If custom (third-party) import hooks are commonly non-thread safe, then
the "global import lock" can still be taken when such an import hook is
called. But built-in import mechanisms can be more tolerant.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8098>
_______________________________________


More information about the Python-bugs-list mailing list