Message 110189 - Python tracker (original) (raw)
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.