Sleep timer but still responsive?
MRAB
python at mrabarnett.plus.com
Fri Jan 29 12:39:31 EST 2010
JohnnyFive wrote:
> On Jan 28, 4:55 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> wrote:
>> Please provide more details. What do you want your program to do while
>> sleeping? What kind of actions do you want a response to?
>> Do you have a GUI? A curses-based interfase?
>>
>> --
>> Gabriel Genellina
>
> My app is purely console based. I just don't want the console to lock
> up (on Windows using time.sleep(x) causes the console to become
> unresponsive until the timer is done), and I want people to be able to
> CTRL+C to stop the script if need be (which can't be done if it's
> unresponsive!).
>
> Thanks.
Which version of Python are you using? time.sleep(x) can be interrupted
in Python 2.6.
If the version you're using can't be interrupted then you could use
multiple sleeps:
# Wait for a total of 10 secs.
for i in range(10):
time.sleep(1)
More information about the Python-list
mailing list