Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6bc2396

Browse files
committed
Issue #21006: Fix subprocess example on Windows in asyncio doc
1 parent 7280486 commit 6bc2396

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Doc/library/asyncio-subprocess.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ it does not use a shell. Get the output of the "python -m platform" command and
146146
display the output::
147147

148148
import asyncio
149+
import os
149150
import sys
150151
from asyncio import subprocess
151152

@@ -164,7 +165,11 @@ display the output::
164165
exitcode = yield from proc.wait()
165166
return (exitcode, stdout)
166167

167-
loop = asyncio.get_event_loop()
168+
if os.name == 'nt':
169+
loop = asyncio.ProactorEventLoop()
170+
asyncio.set_event_loop(loop)
171+
else:
172+
loop = asyncio.get_event_loop()
168173
coro = getstatusoutput(sys.executable, '-m', 'platform')
169174
exitcode, stdout = loop.run_until_complete(coro)
170175
if not exitcode:

0 commit comments

Comments
 (0)