Skip to content

Instantly share code, notes, and snippets.

@objcode
Created August 9, 2011 09:16
Show Gist options
  • Save objcode/1133648 to your computer and use it in GitHub Desktop.
Save objcode/1133648 to your computer and use it in GitHub Desktop.
import signal
class TimerException(Exception): pass
def timeout(signum, frame):
print "signal handler exception", signum
print frame
raise TimerException(frame)
signal.signal(signal.SIGALRM, timeout)
signal.setitimer(signal.ITIMER_REAL, 0.05)
for x in xrange(1000000):
print x
signal.alarm(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment