Abnormal Interpreter Shutdown

Terry Reedy tjreedy at udel.edu
Tue Oct 21 01:33:21 EDT 2008


Tim Golden wrote:
> k3xji wrote:
>> Hi all,
>>
>> Is there anyway to detect abnormal interpreter shutdown like (closing
>> from task manager, power shutdown of the PC..etc)?
> 
> "Task Manager" suggests you're using Windows, on which basis
> you've got a few options open to you, but fundamentally if
> someone pulls the plug on the PC you're not going to spot it.
> 
> Look at the SetConsoleCtrlHandler API[1], which is available
> in the pywin32 package, and the WMI power events[2]. I don't
> know exactly how far each one will go if someone stomps on
> your process, but they're definitely worth looking at.
> 
> TJG
> 
> [1] http://msdn.microsoft.com/en-us/library/ms686016(VS.85).aspx
> [2] http://msdn.microsoft.com/en-us/library/aa394362(VS.85).aspx

If you mean detecting abnormal shutdown after the fact, as opposed to 
catching it while happening, you could create an empty temp file when 
the program starts and delete it upon normal termination.




More information about the Python-list mailing list