Terminate run.py without throwing tracebacks.
Pressing control-c while run.py is being executed has terminated the script, but threw an ugly traceback. To signal the user that his method of exit was appropriate, we handle control-c calling exit(0).
This commit is contained in:
parent
a62a89bca4
commit
a93c0b8f15
|
@ -5,6 +5,7 @@ import importlib
|
||||||
import logging
|
import logging
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -16,6 +17,9 @@ if os.path.exists(os.path.join(our_dir, '../api/zulip')):
|
||||||
|
|
||||||
from zulip import Client
|
from zulip import Client
|
||||||
|
|
||||||
|
def exit_gracefully(signum, frame):
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
class RateLimit(object):
|
class RateLimit(object):
|
||||||
def __init__(self, message_limit, interval_limit):
|
def __init__(self, message_limit, interval_limit):
|
||||||
self.message_limit = message_limit
|
self.message_limit = message_limit
|
||||||
|
@ -147,4 +151,6 @@ def run():
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
original_sigint = signal.getsignal(signal.SIGINT)
|
||||||
|
signal.signal(signal.SIGINT, exit_gracefully)
|
||||||
run()
|
run()
|
||||||
|
|
Loading…
Reference in a new issue