[docs] bug in asyncio-subprocess documentation web pages
Antonio Cacho
ajsccacho at gmail.com
Wed Jan 30 09:46:32 EST 2019
Hi
There is a bug In these asyncio-subprocess web pages:
https://docs.python.org/3.8/library/asyncio-subprocess.html
https://docs.python.org/3.7/library/asyncio-subprocess.html
The bug occurs in the first example program. It lacks the conditional
use of WindowsProactorEventLoopPolicy from the sys package.
The erroneous code and the tested working code are attached.
I couldn't find this bug in the documenting issue tracker, but I doubt
no one has stumbled on it before, and I was in hurry.
Cheers,
Antonio Jose Cacho
---
Este e-mail foi verificado em termos de vírus pelo software antivírus Avast.
https://www.avast.com/antivirus
-------------- next part --------------
import asyncio
async def run(cmd):
proc = await asyncio.create_subprocess_shell(
cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
stdout, stderr = await proc.communicate()
print(f'[{cmd!r} exited with {proc.returncode}]')
if stdout:
print(f'[stdout]\n{stdout.decode()}')
if stderr:
print(f'[stderr]\n{stderr.decode()}')
asyncio.run(run('ls /zzz'))
-------------- next part --------------
import asyncio
import sys
async def run(cmd):
proc = await asyncio.create_subprocess_shell(
cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
stdout, stderr = await proc.communicate()
print(f'[{cmd!r} exited with {proc.returncode}]')
if stdout:
print(f'[stdout]\n{stdout.decode()}')
if stderr:
print(f'[stderr]\n{stderr.decode()}')
if sys.platform == "win32":
asyncio.set_event_loop_policy(
asyncio.WindowsProactorEventLoopPolicy())
asyncio.run(run('dir ..'))
More information about the docs
mailing list