This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author seberg
Recipients jhgoebbert, seberg
Date 2022-03-21.17:28:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1647883724.61.0.954763204287.issue47082@roundup.psfhosted.org>
In-reply-to
Content
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.)
History
Date User Action Args
2022-03-21 17:28:44sebergsetrecipients: + seberg, jhgoebbert
2022-03-21 17:28:44sebergsetmessageid: <1647883724.61.0.954763204287.issue47082@roundup.psfhosted.org>
2022-03-21 17:28:44seberglinkissue47082 messages
2022-03-21 17:28:44sebergcreate