From 2feab82396d960cd412e273dc364f1b1cb881b77 Mon Sep 17 00:00:00 2001 From: Jason Hu Date: Tue, 2 Oct 2018 00:21:02 -0700 Subject: [PATCH] Use Protractor loop in Windows (#17061) * Use Protractor loop in Windows * Add import sys --- homeassistant/util/async_.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/homeassistant/util/async_.py b/homeassistant/util/async_.py index 04456b8cb2f..61fbb60a24f 100644 --- a/homeassistant/util/async_.py +++ b/homeassistant/util/async_.py @@ -2,6 +2,7 @@ import concurrent.futures import threading import logging +import sys from asyncio import coroutines from asyncio.events import AbstractEventLoop from asyncio.futures import Future @@ -22,7 +23,10 @@ except AttributeError: def asyncio_run(main: Awaitable[_T], *, debug: bool = False) -> _T: """Minimal re-implementation of asyncio.run (since 3.7).""" - loop = asyncio.new_event_loop() + if sys.platform == 'win32': + loop = asyncio.ProactorEventLoop() + else: + loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.set_debug(debug) try: