Skip to content

Instantly share code, notes, and snippets.

@Alir3z4
Created July 29, 2013 23:24
Show Gist options
  • Select an option

  • Save Alir3z4/6108778 to your computer and use it in GitHub Desktop.

Select an option

Save Alir3z4/6108778 to your computer and use it in GitHub Desktop.
import signal
class TimeoutError(Exception):
pass
def timeout_handler(signum, frame):
raise TimeoutError('Fuck you time')
def loop_forever(x):
import time
while 1:
print 'item %d' % x
time.sleep(1)
# try: loop_forever()
# except TimeoutError as exc:
# print(exc)
timeout_count = 0
def boom_boom_pow():
for x in xrange(1, 4):
signal.signal(signal.SIGALRM, timeout_handler)
signal.alarm(3)
try: loop_forever(x)
except:
print 'exc'
print 'No printo'
boom_boom_pow()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment