how to call atexit.register for a py03 extension during module initialization #3746
Unanswered
softstream-link
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have written a py03 extension over a rust library which uses threads internally. The problem is I can't get a python script to exist cleanly after the program finishes and it typically exists with Segmentation Fault or a "FATAL: exception not rethrown". After tinkering a bit with various parameters I realized this is happening because the internal Rust thread is still trying to use python interpreter which is in the process of shutting down or already shutdown.
Typically the thread is trying to pass logging via py03_log module or trying to pass a run object into a python callback. In either case it is trying to access the interpreter as it is existing.
Question:
What is the correct way of handling this?
I am trying to register an atexit hook to allow these other threads to terminate cleanly and it seems to work however I am trying trying to do this ergonomically so that the user of extension at least does not need to do this in python script but rather do this in the python extension itself.
I have tried creating a function and calling it in the module registration but it seems to not have any effect.
This is what the function looks like roughly
Beta Was this translation helpful? Give feedback.
All reactions