Sebastian Berg <sebast...@sipsolutions.net> added the comment:
To add to this: it would seem to me that the side-effects of importing should be guaranteed to only be called once? However, IO or other operations could be part of the import side-effects and release the GIL. So even a simple, pure-Python, package could run into this same issue and probably won't even realize that they can run into it. (Assuming I understand how this is happening correctly.) So it would seem to me that either: * Python should lock on the thread level or maybe the `sys.modules` dictionary? * The `threading` module could somehow ensure safety by hooking into the import machinery? * Packages that may release the GIL or have side-effects that must only be run once have to lock (i.e. NumPy). (But it seems to me that many packages will not even be aware of possible issues.) ---------- nosy: +seberg _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47082> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com