Created
February 29, 2012 20:31
-
-
Save felipecruz/1944172 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
def signal_handler(signum, frame): | |
raise Exception("Timed out!") | |
signal.signal(signal.SIGALRM, signal_handler) | |
signal.alarm(10) # Ten seconds | |
try: | |
long_function_call() | |
except Exception: | |
print "Timed out!" |
btw, it works ;)
nice!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
%s/catch/except/
;)