[Tutor] Is there a 'hook' to capture all exits from a python program?

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Mar 18 20:43:51 CET 2015


On 18/03/2015 18:28, Doug Basberg wrote:
> I do real-time controls programming and I control a relay in a python
> program that must be turned off before the program ends.  First, the program
> should never exit unless I do it explicitly.  Is there a 'hook' to process
> before any exit (even if not expected).  I must turn off that relay or harm
> may occur.  Thanks, Doug
>

https://docs.python.org/3/library/atexit.html

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list