Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions kingpin/bin/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
"""CLI Script Runner for Kingpin."""

import argparse
import asyncio
import json
import logging
import os
import sys

from tornado import ioloop

from kingpin import utils
from kingpin.actors import exceptions as actor_exceptions
from kingpin.actors import utils as actor_utils
Expand Down Expand Up @@ -222,23 +221,14 @@ def begin():
utils.setup_root_logger(level=args.level, color=args.color)

try:
ioloop.IOLoop.current().run_sync(main)
asyncio.run(main())
except KeyboardInterrupt:
log.info("CTRL-C Caught, shutting down")
sys.exit(130) # Standard KeyboardInterrupt exit code.
except Exception:
# Skip traceback that involves tornado's libraries.
import traceback

trace_lines = traceback.format_exc().splitlines()
skip_next = False
for l in trace_lines:
if "tornado" in l:
skip_next = True
continue
if not skip_next:
print(l)
skip_next = False
traceback.print_exc()
sys.exit(3)


Expand Down
3 changes: 1 addition & 2 deletions kingpin/bin/test/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ def test_begin_with_debug(self):
)
def test_begin_keyboard_interrupt(self):
self._import_kingpin_bin_deploy()
with mock.patch("tornado.ioloop.IOLoop.current") as mock_ioloop_current:
mock_ioloop_current.side_effect = KeyboardInterrupt()
with mock.patch("asyncio.run", side_effect=KeyboardInterrupt()):
with self.assertRaises(SystemExit) as cm:
self.kingpin_bin_deploy.begin()
self.assertEqual(cm.exception.code, 130)
Loading