-
-
Save whymarrh/119730855d372409dabcd4b1a06a91c9 to your computer and use it in GitHub Desktop.
Exit graceful on SIGPIPE
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 -u | |
from __future__ import print_function | |
import signal | |
import sys | |
import time | |
def exit_graceful(sig, frame): | |
print('GRACEFUL', file=open("was-graceful.log", "wt")) | |
sys.exit(0) | |
signal.signal(signal.SIGPIPE, exit_graceful) | |
try: | |
i = 0 | |
while True: | |
i += 1 | |
print(i) | |
time.sleep(1) | |
except Exception as e: | |
raise e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment