Abnormal Interpreter Shutdown

Tim Golden mail at timgolden.me.uk
Mon Oct 20 15:22:17 EDT 2008


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



More information about the Python-list mailing list