From 6b13486acf39db02b247bc30802914f067e3d6bd Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 10 Feb 2017 17:04:38 +0200 Subject: [PATCH] Fix exception that asyncio throws on GC --- homeassistant/__main__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/homeassistant/__main__.py b/homeassistant/__main__.py index d9ab410b745600..b73c1eef5d52c4 100644 --- a/homeassistant/__main__.py +++ b/homeassistant/__main__.py @@ -365,7 +365,14 @@ def main() -> int: if args.script is not None: from homeassistant import scripts - return scripts.run(args.script) + # https://github.com/python/asyncio/pull/456 + # Bug in asyncio throws exception unless loop is closed. + import asyncio + res = scripts.run(args.script) + loop = asyncio.get_event_loop() + if loop is not None: + loop.close() + return res config_dir = os.path.join(os.getcwd(), args.config) ensure_config_path(config_dir)