Created
July 29, 2013 23:24
-
-
Save Alir3z4/6108778 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 | |
| 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