how to interrupt time.sleep ?
Thomas Heller
theller at python.net
Wed Feb 23 02:48:10 EST 2005
BOOGIEMAN <BOOGIEMANPN at YAHOO.COM> writes:
> I have line "time.sleep(60)" in my code
>
> How do I cancel waiting 60 seconds if I want to continue with program
> imediately ? Like "Press some button if you don't want to wait"
>
> If it can't be canceled what's the other solution to
> "wait certain time/or press any button to continue" problem ?
On windows at least, pressing ^C interrupts time.sleep().
print "Press ^C if you don't want to wait"
try:
time.sleep(60)
except KeyboardInterrupt:
pass
Thomas
More information about the Python-list
mailing list