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 vstinner
Recipients corona10, eric.snow, vstinner
Date 2020-05-11.22:12:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589235149.46.0.0630975096351.issue40600@roundup.psfhosted.org>
In-reply-to
Content
When a C extension module is created with PyModuleDef_Init(), it becomes possible to create more than one instance of the module.

It would take significant effort to modify some extensions to make their code fully ready to have two isolated module.

For example, the atexit module calls _Py_PyAtExit() to register itself into the PyInterpreterState. If the module is created more than once, the most recently created module wins, and calls registered on other atexit instances are ignore: see bpo-40288.

One simple option would be to simply disallow loading the module more than once per interpreter.

Also, some extensions are not fully compatible with subinterpreters. It may be interesting to allow to load them in a subinterpreter if it's not already loaded in another interpreter, like another subinterpreter or the main interpreter. It would be only load it once per Python *process*. For example, numpy would be a good candidate for such option.

I'm not sure fow a module should announced in its definition that it should not be loaded more than once.
History
Date User Action Args
2020-05-11 22:12:29vstinnersetrecipients: + vstinner, eric.snow, corona10
2020-05-11 22:12:29vstinnersetmessageid: <1589235149.46.0.0630975096351.issue40600@roundup.psfhosted.org>
2020-05-11 22:12:29vstinnerlinkissue40600 messages
2020-05-11 22:12:29vstinnercreate