[Tutor] Is there a 'hook' to capture all exits from a python program?
Albert-Jan Roskam
fomcl at yahoo.com
Wed Mar 18 21:13:01 CET 2015
-----------------------------
On Wed, Mar 18, 2015 8:43 PM CET Mark Lawrence wrote:
>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
... But that's only for normal program termination; sys.excepthook is for unexpected exits. I would be interested to hear about a module that does both.
More information about the Tutor
mailing list