From edc0d7f2c74d564b0468f27e9eb53e438284dd6a Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 15 Nov 2019 20:10:17 +0100 Subject: [PATCH] Fix non-terminating bot --- freqtrade/main.py | 3 --- freqtrade/utils.py | 11 +++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/freqtrade/main.py b/freqtrade/main.py index 0a2adf71a..7afaeb1a2 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -27,7 +27,6 @@ def main(sysargv: List[str] = None) -> None: """ return_code: Any = 1 - worker = None try: arguments = Arguments(sysargv) args = arguments.get_parsed_arg() @@ -57,8 +56,6 @@ def main(sysargv: List[str] = None) -> None: except Exception: logger.exception('Fatal exception!') finally: - if worker: - worker.exit() sys.exit(return_code) diff --git a/freqtrade/utils.py b/freqtrade/utils.py index 5ad134ef9..ff54790a5 100644 --- a/freqtrade/utils.py +++ b/freqtrade/utils.py @@ -45,8 +45,15 @@ def start_trading(args: Dict[str, Any]) -> int: """ from freqtrade.worker import Worker # Load and run worker - worker = Worker(args) - worker.run() + try: + worker = Worker(args) + worker.run() + except KeyboardInterrupt: + logger.info('SIGINT received, aborting ...') + finally: + if worker: + logger.info("worker found ... calling exit") + worker.exit() return 0