Skip to content

Instantly share code, notes, and snippets.

@ozancaglayan
Last active February 20, 2016 12:17
Show Gist options
  • Save ozancaglayan/b7fdd086616eb986114e to your computer and use it in GitHub Desktop.
Save ozancaglayan/b7fdd086616eb986114e to your computer and use it in GitHub Desktop.
#!/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