asyncio, tulip issue 190: Process.communicate() must ignore BrokenPipeError

If you want to handle the BrokenPipeError, you can easily reimplement
communicate().

Add also a unit test to ensure that stdin.write() + stdin.drain() raises
BrokenPipeError.
This commit is contained in:
Victor Stinner 2014-07-17 12:25:27 +02:00
parent 38bf87c7f2
commit cc996b5789
3 changed files with 32 additions and 8 deletions

View file

@ -143,7 +143,11 @@ class Process:
if self._loop.get_debug():
logger.debug('%r communicate: feed stdin (%s bytes)',
self, len(input))
yield from self.stdin.drain()
try:
yield from self.stdin.drain()
except BrokenPipeError:
# ignore BrokenPipeError
pass
if self._loop.get_debug():
logger.debug('%r communicate: close stdin', self)