From 0383fadaa10f7e9af7682d55eadf66526c4dff69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@stuvel.eu> Date: Fri, 3 Mar 2017 17:54:18 +0100 Subject: [PATCH] (hopefully) fixed race condition between HTTP connection and shutdown. If the keyboard interrupt is received while the "may I run" task is just connecting to the Manager, it would cause an exception that would halt the graceful shutdown. --- flamenco_worker/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flamenco_worker/cli.py b/flamenco_worker/cli.py index 2de2df59..465b98e1 100644 --- a/flamenco_worker/cli.py +++ b/flamenco_worker/cli.py @@ -5,6 +5,8 @@ import asyncio import logging import logging.config +import requests + def main(): parser = argparse.ArgumentParser() @@ -98,7 +100,10 @@ def main(): except KeyboardInterrupt: shutdown_future.cancel() mir_work_task.cancel() - loop.run_until_complete(mir_work_task) + try: + loop.run_until_complete(mir_work_task) + except requests.exceptions.ConnectionError: + log.warning("Unable to connect to HTTP server, but that's fine as we're shutting down.") fworker.shutdown() -- GitLab