Commit c419caff authored by Victor Stinner's avatar Victor Stinner

Issue #21006: Fix subprocess example on Windows in asyncio doc

parent bac6248e
...@@ -146,6 +146,7 @@ it does not use a shell. Get the output of the "python -m platform" command and ...@@ -146,6 +146,7 @@ it does not use a shell. Get the output of the "python -m platform" command and
display the output:: display the output::
import asyncio import asyncio
import os
import sys import sys
from asyncio import subprocess from asyncio import subprocess
...@@ -164,6 +165,10 @@ display the output:: ...@@ -164,6 +165,10 @@ display the output::
exitcode = yield from proc.wait() exitcode = yield from proc.wait()
return (exitcode, stdout) return (exitcode, stdout)
if os.name == 'nt':
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
else:
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
coro = getstatusoutput(sys.executable, '-m', 'platform') coro = getstatusoutput(sys.executable, '-m', 'platform')
exitcode, stdout = loop.run_until_complete(coro) exitcode, stdout = loop.run_until_complete(coro)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment