]> granicus.if.org Git - python/commitdiff
Issue #21006: Fix subprocess example on Windows in asyncio doc
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 21 Mar 2014 10:56:40 +0000 (11:56 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 21 Mar 2014 10:56:40 +0000 (11:56 +0100)
Doc/library/asyncio-subprocess.rst

index 26bc629452b97cfe0b784a56086213fc6e70da70..37be849a01f1ca47303e7f2d8bab97a861cbf3a0 100644 (file)
@@ -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: