Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bartoszbielawski/a92801856ad2eb57dbfadd993cd5f601 to your computer and use it in GitHub Desktop.
Save bartoszbielawski/a92801856ad2eb57dbfadd993cd5f601 to your computer and use it in GitHub Desktop.
jpype && KeyboardInterrupt
#!/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