diff --git a/contrib_bots/run.py b/contrib_bots/run.py index 06a3ad5..89a20c1 100755 --- a/contrib_bots/run.py +++ b/contrib_bots/run.py @@ -5,6 +5,7 @@ import importlib import logging import optparse import os +import signal import sys import time @@ -16,6 +17,9 @@ if os.path.exists(os.path.join(our_dir, '../api/zulip')): from zulip import Client +def exit_gracefully(signum, frame): + sys.exit(0) + class RateLimit(object): def __init__(self, message_limit, interval_limit): self.message_limit = message_limit @@ -147,4 +151,6 @@ def run(): ) if __name__ == '__main__': + original_sigint = signal.getsignal(signal.SIGINT) + signal.signal(signal.SIGINT, exit_gracefully) run()