Latest recipes tagged "exit" but not "status" and "sigterm"http://code.activestate.com/recipes/tags/exit-status-sigterm/new/2016-05-31T00:42:47-07:00ActiveState Code RecipesRegister exit function (Python)
2016-05-31T00:42:47-07:00Giampaolo RodolĂ http://code.activestate.com/recipes/users/4178764/http://code.activestate.com/recipes/580672-register-exit-function/
<p style="color: grey">
Python
recipe 580672
by <a href="/recipes/users/4178764/">Giampaolo RodolĂ </a>
(<a href="/recipes/tags/exit/">exit</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/signal/">signal</a>).
Revision 3.
</p>
<p>This is a function / decorator which registers a function which will be executed on "normal" interpreter exit or in case one of the <code>signals</code> is received by this process (differently from atexit.register()). Also, it makes sure to execute any other function which was previously registered via signal.signal(). If any, it will be executed after our own <code>fun</code>. The full blogpost explaining why you should use this instead of atexit module is here: <a href="http://grodola.blogspot.com/2016/02/how-to-always-execute-exit-functions-in-py.html" rel="nofollow">http://grodola.blogspot.com/2016/02/how-to-always-execute-exit-functions-in-py.html</a></p>