Author mwf
Recipients gvanrossum, mwf, vstinner, yselivanov
Date 2015-04-01.10:06:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Script attached which reproduces the issue.

Steps to reproduce:
0) Use python 3.4.3 on Linux. Does not repro with 3.4.0 or 3.4.2.
1) Create a child process with asyncio.create_child_exec and stdout=PIPE
2) loop yield from (i used n=2048, any other positive value < StreamRead._limit ought to work too)
3) Write >= StreamRead._limit * 2 + 1 (by default 2**17+1) bytes from child process and exit

File referenced below: asyncio/

feed_data is called when data arrives from the child process. Having more than 2 * self._limit bytes in self._buffer will lead to StreamReader pausing reading on line 372.

feed_eof sets self._eof to True, but that value is not checked in relevant sections later.

Child process exits, which will lead to self._loop = None being set apparently on line 405 of _UnixReadPipeTransport._call_connection_lost in asyncio/ (could not find any other location where it would be set to None).

After a number of read()s, self._maybe_resume_transport() is called when len(self._buffer) <= self._limit (ie. <= 64k left in buffer). self._paused will evaluate true too, so self._transport.resume_reading() is called on line 349.

That will call self._loop.add_reader(self._fileno, self._read_ready) on line 364 of asyncio/ self._loop is None, so and AttributeError is raised when None has no add_reader attribute:

Traceback (most recent call last):
  File "", line 29, in <module>
    print('read {} bytes from child'.format(loop.run_until_complete(fail())))
  File "/home/frojma/python-3.4.3/lib/python3.4/asyncio/", line 316, in run_until_complete
    return future.result()
  File "/home/frojma/python-3.4.3/lib/python3.4/asyncio/", line 275, in result
    raise self._exception
  File "/home/frojma/python-3.4.3/lib/python3.4/asyncio/", line 238, in _step
    result = next(coro)
  File "", line 15, in fail
    chunk = yield from
  File "/home/frojma/python-3.4.3/lib/python3.4/asyncio/", line 478, in read
  File "/home/frojma/python-3.4.3/lib/python3.4/asyncio/", line 354, in _maybe_resume_transport
  File "/home/frojma/python-3.4.3/lib/python3.4/asyncio/", line 364, in resume_reading
    self._loop.add_reader(self._fileno, self._read_ready)
Date User Action Args
2015-04-01 10:06:02mwfsetrecipients: + mwf, gvanrossum, vstinner, yselivanov
2015-04-01 10:06:02mwfsetmessageid: <>
2015-04-01 10:06:02mwflinkissue23837 messages
2015-04-01 10:06:01mwfcreate