From 8151b952b9f5b6ae5833c2a3d2cf0c3a2ae31c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 17 Jan 2017 16:02:34 +0100 Subject: [PATCH] Construct ProactorEventLoop on win32 for subprocess support --- blender_cloud/async_loop.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/blender_cloud/async_loop.py b/blender_cloud/async_loop.py index aeeb67a..478196b 100644 --- a/blender_cloud/async_loop.py +++ b/blender_cloud/async_loop.py @@ -39,9 +39,18 @@ def setup_asyncio_executor(): calls that could be performed in parallel are queued, and thus we can reliably cancel them. """ + import sys executor = concurrent.futures.ThreadPoolExecutor() - loop = asyncio.get_event_loop() + + if sys.platform == 'win32': + # On Windows, the default event loop is SelectorEventLoop, which does + # not support subprocesses. ProactorEventLoop should be used instead. + # Source: https://docs.python.org/3/library/asyncio-subprocess.html + loop = asyncio.ProactorEventLoop() + asyncio.set_event_loop(loop) + else: + loop = asyncio.get_event_loop() loop.set_default_executor(executor) # loop.set_debug(True)