diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-03-21 10:56:40 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-03-21 10:56:40 (GMT) |
commit | 6bc239619ce93840ac3a3379dcbb32baa8e94e0e (patch) | |
tree | dc325d911dd6fa529fbdfb3c345d7a911f9bad30 | |
parent | 7280486ce34266047a54310435299de045c4d07f (diff) | |
download | cpython-6bc239619ce93840ac3a3379dcbb32baa8e94e0e.zip cpython-6bc239619ce93840ac3a3379dcbb32baa8e94e0e.tar.gz cpython-6bc239619ce93840ac3a3379dcbb32baa8e94e0e.tar.bz2 |
Issue #21006: Fix subprocess example on Windows in asyncio doc
-rw-r--r-- | Doc/library/asyncio-subprocess.rst | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst index 26bc629..37be849 100644 --- a/Doc/library/asyncio-subprocess.rst +++ b/Doc/library/asyncio-subprocess.rst @@ -146,6 +146,7 @@ it does not use a shell. Get the output of the "python -m platform" command and display the output:: import asyncio + import os import sys from asyncio import subprocess @@ -164,7 +165,11 @@ display the output:: exitcode = yield from proc.wait() return (exitcode, stdout) - loop = asyncio.get_event_loop() + if os.name == 'nt': + loop = asyncio.ProactorEventLoop() + asyncio.set_event_loop(loop) + else: + loop = asyncio.get_event_loop() coro = getstatusoutput(sys.executable, '-m', 'platform') exitcode, stdout = loop.run_until_complete(coro) if not exitcode: |