On Wed, Jul 14, 2010 at 12:34, Antoine Pitrou <report@bugs.python.org> wrote:

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

> So I say we don't worry about loaders being thread-safe. If __import__
> handles the locking for a specific module then it will hold the lock
> on behalf of the loader.

Yes but what happens if two different modules are imported from two
different threads, and handled by the same loader? The loader could have
global structures which rely on serialization of imports for
consistency.

That's why I said we should supply a context decorator (or function) which will handle the lock appropriately, taking the name of the module to import as an argument so the locking is fine-grained.