StreamReader.read(-1) deadlocks while reading from a pipe

177 views
Skip to first unread message

Akira Li

unread,
May 9, 2014, 4:37:05 PM5/9/14
to python...@googlegroups.com
Hi,

stream.read() blocks forever when reading from a pipe with data that is larger than 2 * limit.
stream.read(n) for non-negative n doesn't deadlock in this case.

For example, if asyncio.StreamReader(loop=loop) is replaced with
asyncio.StreamReader(loop=loop, limit=(len(b'data') // 2 - 1))
in examples/subprocess_attach_read_pipe.py then
yield from reader.read() never returns.


It is reproducible for larger limit values if the data to be send is larger than 2*limit.

I've attached the test file that demonstrates it without an external process.

Is it the correct way to connect a read pipe to the event loop?

Related discussion: 
test_unlimited_read_from_pipe.py

Guido van Rossum

unread,
May 9, 2014, 6:51:42 PM5/9/14
to Akira Li, python-tulip
Hi Akira,

Thanks for reporting this. There definitely is a bug in asyncio here -- I can repro this exactly!

I haven't found a fix yet, but it seems we're not making progress when the protocol is paused.

If I don't get further today I'll file a bug to track this.
--
--Guido van Rossum (python.org/~guido)

Guido van Rossum

unread,
May 11, 2014, 8:12:36 PM5/11/14
to Akira Li, python-tulip
I've now opened https://code.google.com/p/tulip/issues/detail?id=168 so we have a place to refer to when I have a fix.

Guido van Rossum

unread,
May 12, 2014, 1:08:22 PM5/12/14
to python...@googlegroups.com, Akira Li, gu...@python.org
This is now fixed in the Tulip repo and in the CPython 3.4 and default branches. Akira, thanks for reporting this issue!
Reply all
Reply to author
Forward
0 new messages