[BUG]: Cannot reset pybind11 state to "freshly started"
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
dc9b39596d986aeb061bd3debe52d30e2467dc48
Problem description
Hi,
In my project i use embedded python and this uses a python wrapper which is made with pybind11.
The Application needs to start the embedded python interpreter several times and also finishes it nicely with Py_FinalizeEx()
Now the problem is:
embedded python is started the 2nd time,
python starts
python imports a module made with pybind11
Now I get the error: ImportError: generic_type: type "BRepLib_ShellError" is already registered!
I believe that the problem is in
inline internals **&get_internals_pp(){
static internals **internals_pp = nullptr;
}
I could not find any mechanism, which can reset this structure. This file should be reset at the same time when i call Py_FinalzeEx()
if that exist, please let me know!
Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
Not a regression
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported get_internals_pp() entry point and the lifecycle around Py_FinalizeEx() and repeated embedded-interpreter startup. There is no reproducible example or file path in the issue, so first trace how pybind11 state is created and retained across interpreter restarts. Done means establishing whether reset support is possible and documenting or addressing the repeated-import failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100