Re: [Python-ideas] Context manager to temporarily set signal handlers

2017-01-22 Thread Giampaolo Rodola'
I don't know if this is related (regarding functions registered in C) but one problem I often have is to always execute exit functions. I have come up with this: http://grodola.blogspot.com/2016/02/how-to-always-execute-exit-functions-in-py.html On Fri, Jan 20, 2017 at 1:46 PM, Thomas Kluyver

[Python-ideas] Context manager to temporarily set signal handlers

2017-01-20 Thread Thomas Kluyver
Not uncommonly, I want to do something like this in code: import signal # Install my own signal handler prev_hup = signal.signal(signal.SIGHUP, my_handler) prev_term = signal.signal(signal.SIGTERM, my_handler) try: do_something_else() finally: # Restore previous signal handlers