time.sleep() under Windows

Gerhard Häring gerhard.haering at opus-gmbh.net
Fri Jan 17 09:45:34 CET 2003


Chuck <cdreward at riaa.com> wrote:
> 
> In Windows 98, if I type:
> 
> time.sleep(5)
> 
> in the python shell (GUI or console), the shell itself locks up for 5
> seconds, and I cannot stop it with a CTRL-C (or rather, it does not
> respond to the CTRL-C until all 5 seconds have passed).

That's normal. I believe Ctrl-C only works if anything is currently going
on with the stdin/out/err files.

Btw. try Ctrl-Break (on the Pause key) - it works here to interrupt
time.sleep on Windows 2000.

> The python shell locks up - I cannot move the window, minimize it, etc.

Sounds like a Win98 issue.

> The same script, in Linux, runs the way I want it (you can CTRL-C it, the
> interpreter doesn't lock up, etc). I realize this is just a platform issue...
> But is there something else besides time.sleep() that I can use, that is
> platform independent?

There are many functions in the Python standard library that are platform
independent ;-) But for actually sleeping, I think time.sleep is the only
option. But maybe your app doesn't really need to sleep but wait on data to
become available? In that case, you could use select.select instead.

Gerhard
-- 
Gerhard Häring
OPUS GmbH München
Tel.: +49 89 - 889 49 7 - 32
http://www.opus-gmbh.net/




More information about the Python-list mailing list