From c419caffe896e98f6efaab41e70dc29a51f63fae Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 21 Mar 2014 11:56:40 +0100 Subject: [PATCH] Issue #21006: Fix subprocess example on Windows in asyncio doc --- Doc/library/asyncio-subprocess.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst index 26bc629452b..37be849a01f 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: