RosettaCodeData/Task/Handle-a-signal/Python/handle-a-signal-2.py

19 lines
318 B
Python
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
import time
2013-04-10 21:29:02 -07:00
2015-02-20 00:35:01 -05:00
def intrptWIN():
procDone = False
n = 0
2013-04-10 21:29:02 -07:00
2015-02-20 00:35:01 -05:00
while not procDone:
try:
time.sleep(0.5)
n += 1
print n
except KeyboardInterrupt, e:
procDone = True
2013-04-10 21:29:02 -07:00
t1 = time.time()
2015-02-20 00:35:01 -05:00
intrptWIN()
2013-04-10 21:29:02 -07:00
tdelt = time.time() - t1
print 'Program has run for %5.3f seconds.' % tdelt