Construct ProactorEventLoop on win32 for subprocess support

This commit is contained in:
Sybren A. Stüvel 2017-01-17 16:02:34 +01:00
parent 2d2585b8d7
commit 8151b952b9

View File

@ -39,9 +39,18 @@ def setup_asyncio_executor():
calls that could be performed in parallel are queued, and thus we can calls that could be performed in parallel are queued, and thus we can
reliably cancel them. reliably cancel them.
""" """
import sys
executor = concurrent.futures.ThreadPoolExecutor() 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_default_executor(executor)
# loop.set_debug(True) # loop.set_debug(True)