time.sleep() under Windows

Tim Peters tim.one at comcast.net
Fri Jan 17 16:18:37 EST 2003


[Thomas Heller]
> That may be, but the behaviour has changed in Python 2.3, at least
> if you're using Win2k. Now you can interrupt the time.sleep() call
> with CTRL-C, and Python can catch a KeyboardError,

KeyboardInterrupt, actually.

> which CTLR-Creak still terminates the process.

CTRL-Break, and it does, but you *can* install a CTRL-Break handler, if you
like:  while the signal module is overwhelmingly useless on Windows, it does
support a Windows-specific SIGBREAK signal.  This was new in 2.2 (and
details are in the 2.2b1 section of the NEWS files).

> Mark Hammond implemented this IIRC,

Yes.

> it's amazing how complicated this is.

Jaw-dropping.  It was also enabled on Win9x, but I tested that and it caused
system (OS) instability there.  We're never going to know why, so the
ability to interrupt sleep() on Win9x was ripped out again.






More information about the Python-list mailing list