You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use pybind11 embedded modules in a software repository where Py_Initialize() is already called by another python embedding framework (which I unfortunately cannot touch or modify). Hence, I cannot use initialize_interpreter() or scoped_interpreter as it will crash as the interpreter is already initialized.
My code still works if I simply skip calling initialize_interpreter(), since the interpreter has already been initialized and everything works. But, I am wondering if it is safe to do so. Here's what the doc says - "Do not use the raw CPython API functions Py_Initialize and Py_Finalize as these do not properly handle the lifetime of pybind11’s internal data."
Is the side-effect of using Py_Initialize() instead of pybind11::initialize_interpreter() is memory leaks or something even more sinister? Is there an alternate initialization function I can call that skips reinitializing the interpreter (if already initialized)?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to use pybind11 embedded modules in a software repository where Py_Initialize() is already called by another python embedding framework (which I unfortunately cannot touch or modify). Hence, I cannot use initialize_interpreter() or scoped_interpreter as it will crash as the interpreter is already initialized.
My code still works if I simply skip calling initialize_interpreter(), since the interpreter has already been initialized and everything works. But, I am wondering if it is safe to do so. Here's what the doc says - "Do not use the raw CPython API functions Py_Initialize and Py_Finalize as these do not properly handle the lifetime of pybind11’s internal data."
Is the side-effect of using Py_Initialize() instead of pybind11::initialize_interpreter() is memory leaks or something even more sinister? Is there an alternate initialization function I can call that skips reinitializing the interpreter (if already initialized)?
Thanks and appreciate your help.
Beta Was this translation helpful? Give feedback.
All reactions