[portland] Detecting System Standby on Windows

Ron Jackson Ron at FascinatingElectronics.com
Wed Jul 16 08:15:18 CEST 2008


Judging by the number of Mac and Linux laptops at the meetings, I
would guess that most people are not working on Windows.

Anyway, I'm building a specialized Python USB library for
communication class devices (which show up as com ports).

I've run into problems when Windows goes into Standby. During the 5
seconds or so that the Python continues to run as Windows is shutting
down things, my library is continuing to pound on the serial port as
it is asynchronously shutting down. This has a tendency to cause the
win32file.ReadFile function on the port to lock up and requires a
physical disconnect to clear.

Is there some way to detect that Windows has started to go into
standby before Python is halted? If I had a status function I could
call to make sure no standby was immanent that would likely solve my
problem.

Thanks for the help!

  -- Ron


More information about the Portland mailing list