Message 58272 - Python tracker (original) (raw)
The patch adds a new API method _PyImport_ImportModuleNoLock(const char *name). It works mostly like PyImport_ImportModule except it does not block. It tries to fetch the module from sys.modules first and falls back to PyImport_ImportModule UNLESS the import lock is held by another thread.
It fixes several issues related to dead locks when a thread uses a function that imports a module but another thread holds the lock. It doesn't require static caching of modules.
The patch is against py3k but I can backport it to 2.6.