RosettaCodeData/Task/Handle-a-signal/Python/handle-a-signal-1.py
2015-02-20 00:35:01 -05:00

15 lines
297 B
Python

import time
def counter():
n = 0
t1 = time.time()
while True:
try:
time.sleep(0.5)
n += 1
print n
except KeyboardInterrupt, e:
print 'Program has run for %5.3f seconds.' % (time.time() - t1)
break
counter()