Properly handle KeyboardInterrupt exception in CLI in macOS

This commit is contained in:
Micah Lee 2017-02-22 13:35:34 -08:00
parent 9be8169233
commit a57703cb5a
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73

View File

@ -199,8 +199,10 @@ def main(cwd=None):
# wait for app to close
while t.is_alive():
# t.join() can't catch KeyboardInterrupt in such as Ubuntu
t.join(0.5)
t.join()
# allow KeyboardInterrupt exception to be handled with threads
# https://stackoverflow.com/questions/3788208/python-threading-ignores-keyboardinterrupt-exception
time.sleep(100)
except KeyboardInterrupt:
web.stop(app.port)
finally: