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 christoph.wiedemann
Recipients christoph.wiedemann
Date 2018-08-01.17:36:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1533144973.44.0.56676864532.issue34309@psf.upfronthosting.co.za>
In-reply-to
Content
I'm linking an issue from numpy here: https://github.com/numpy/numpy/issues/8097

Embedding python suffers from a possibility to reliably reset the state of the python interpreter. For my use case, I noticed that when using numpy with Py_Initialize() and Py_Finalize():

Py_Initialize()
// call code importing numpy
Py_Finalize()
Py_Initialize()
// call same code again

The above code will result in a crash.

One of the comments in the referenced issue is that Py_Finalize doesn't unload loaded DLL's or shared objects. Doing that would probably fix the issues.

As of now, embedding python is fundamentally broken for applications which want to embed non-trivial scientific python scripts involving user-adapted python code, because

a) Py_Finalize cannot be used reliably
b) There is no possibility to reliably reset the python interpreter otherwise (because the sub-interpreters are also not working reliably, which is stated in the documentation)
c) manually reloading changed modules via importlib.reload is not a feasible solution

The possibility to reset an embedded python interpreter to an initial state is a strong requirement for such applications.
History
Date User Action Args
2018-08-01 17:36:13christoph.wiedemannsetrecipients: + christoph.wiedemann
2018-08-01 17:36:13christoph.wiedemannsetmessageid: <1533144973.44.0.56676864532.issue34309@psf.upfronthosting.co.za>
2018-08-01 17:36:13christoph.wiedemannlinkissue34309 messages
2018-08-01 17:36:13christoph.wiedemanncreate