]> granicus.if.org Git - python/commitdiff
asyncio.subprocess: Fix a race condition in communicate()
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 20 Feb 2014 09:12:59 +0000 (10:12 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 20 Feb 2014 09:12:59 +0000 (10:12 +0100)
Use self._loop instead of self._transport._loop, because transport._loop is set
to None at process exit.

Lib/asyncio/subprocess.py

index c3b01755525ab730ad88f13a1f7eb12b610d3319..414e02383e4ea1a42dab8edf3b3035718a77bd76 100644 (file)
@@ -146,7 +146,6 @@ class Process:
 
     @tasks.coroutine
     def communicate(self, input=None):
-        loop = self._transport._loop
         if input:
             stdin = self._feed_stdin(input)
         else:
@@ -160,7 +159,7 @@ class Process:
         else:
             stderr = self._noop()
         stdin, stdout, stderr = yield from tasks.gather(stdin, stdout, stderr,
-                                                        loop=loop)
+                                                        loop=self._loop)
         yield from self.wait()
         return (stdout, stderr)