-
I hope this is the right place to ask. I am working on a C++ library that is tightly coupled with a C library. The C lib needs to allocate some global state and the user is expected to call an init function and an exit function at program start and end respectively. What is the best approach for the Python binding? Right now I call the init function in my main NB_MODULE definition. Is there a way to register a function on termination of the Python interpreter without exposing the exit function to the Python end user? I found atexit, but I don't see a way to call this function without exposing the exit function to the Python end user. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've found an answer in pybind11`s documentation: One can use the atexit module like this:
I think that solves my question. |
Beta Was this translation helpful? Give feedback.
I've found an answer in pybind11`s documentation:
One can use the atexit module like this:
I think that solves my question.