python - Is registered atexit handler inherited by spawned child processes? -


I am writing a daemon program through Python 2.5. In the main process, an exit handler is registered with the atexit module; it looks that the handler is called when every child's process is finished , Which I did not expect.

I see that this behavior has not been told in dragon atexit doctor, anybody knows this issue? If this should behave like this, how can I unregister the handling handle in children's processes? Version 3.0 has an atexit.unregister, but I'm using 2.5.

There is no API to do it in Python 2.5, but you can do it:

  import ataxit atexit._exithandlers = []  

In the process of your child - if you know that you have only one exit handler installed, And that no other handler is installed. However, keep in mind that parts of stdlib (such as logging ) register atexit handler. To avoid harvesting them, you can try:

  my_handler_entries = [atexit._exithandlers for e if e [0] == my_handler_func] in my_handler_entries for e: atexit ._exithandlers.remove (e)  

where my_handler_func to is atexit handler you register, and you do it without deleting others The entry should be removed.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -