[issue23068] Add a way to determine if the current thread has the import lock

Nick Coghlan report at bugs.python.org
Thu Dec 18 00:14:40 CET 2014


Nick Coghlan added the comment:

Looking at the implementation of PyImport_ImportModuleNoBlock, you should be able to invoke that via ctypes with a nonsense module name to probe for whether or not the current thread has the import lock.

A call like 'PyImport_ImportModuleNoBlock("this-is-not-a-legal-module-name")' will always fail with ImportError, but the exception message will be different if another thread holds the import lock. Specifically, it will end with "because the import lock is held by another thread".

----------

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


More information about the Python-bugs-list mailing list