Created
August 10, 2017 19:31
-
-
Save bartoszbielawski/a92801856ad2eb57dbfadd993cd5f601 to your computer and use it in GitHub Desktop.
jpype && KeyboardInterrupt
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
#!/bin/env python | |
from time import sleep | |
import signal | |
from jpype import * | |
startJVM(getDefaultJVMPath()) | |
def handler(signum, frame): | |
raise KeyboardInterrupt | |
#the overloaded signal handling has to be here to make KeyboardInterrupt work again | |
#please comment out to check how the script dies without doing any clean-up | |
signal.signal(signal.SIGINT, handler) | |
try: | |
while True: | |
print(".", end="", flush=True) | |
sleep(1) | |
except BaseException as e: | |
print(e, type(e)) | |
finally: | |
print("This should be always executed", flush=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment