asyncio, tulip issue 190: Process.communicate() now ignores

ConnectionResetError too
This commit is contained in:
Victor Stinner 2014-07-17 13:12:03 +02:00
parent cc996b5789
commit d55b54d5c0
2 changed files with 12 additions and 9 deletions

View file

@ -139,17 +139,19 @@ class Process:
@coroutine
def _feed_stdin(self, input):
debug = self._loop.get_debug()
self.stdin.write(input)
if self._loop.get_debug():
if debug:
logger.debug('%r communicate: feed stdin (%s bytes)',
self, len(input))
try:
yield from self.stdin.drain()
except BrokenPipeError:
# ignore BrokenPipeError
pass
except (BrokenPipeError, ConnectionResetError) as exc:
# communicate() ignores BrokenPipeError and ConnectionResetError
if debug:
logger.debug('%r communicate: stdin got %r', self, exc)
if self._loop.get_debug():
if debug:
logger.debug('%r communicate: close stdin', self)
self.stdin.close()