Construct ProactorEventLoop on win32 for subprocess support
This commit is contained in:
parent
2d2585b8d7
commit
8151b952b9
@ -39,8 +39,17 @@ 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()
|
||||||
|
|
||||||
|
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 = asyncio.get_event_loop()
|
||||||
loop.set_default_executor(executor)
|
loop.set_default_executor(executor)
|
||||||
# loop.set_debug(True)
|
# loop.set_debug(True)
|
||||||
|
Reference in New Issue
Block a user