Last active
February 20, 2016 12:17
-
-
Save ozancaglayan/b7fdd086616eb986114e to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import sys | |
import time | |
def model(): | |
print "model" | |
try: | |
while 1: | |
print "loop" | |
time.sleep(2) | |
print "awake" | |
a = [] | |
# Trigger exceptiom | |
print a[0] | |
except Exception as e: | |
raise | |
except KeyboardInterrupt as ke: | |
print "model interrupted." | |
finally: | |
print "finally" | |
raise KeyboardInterrupt("Interrupted") | |
if __name__ == '__main__': | |
try: | |
model() | |
except KeyboardInterrupt as ke: | |
pass | |
finally: | |
print "finally outer block" | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment