New submission from skorpeo <skorpe...@gmail.com>:

I humbly submit what I think may be a bug in the asyncio.StreamReader.read() 
function.  When n=-1 is supplied and the data is less than self._limit the read 
function creates a future and never wakes it up.  I believe the culprit is 
https://github.com/python/cpython/blob/9d3627e311211a1b4abcda29c36fe4afe2c46532/Lib/asyncio/streams.py#L632.
  To fix the issue a condition is added to break out of the loop if the data 
read is less than the limit.  I can only attach one file so I am providing the 
fix here for asyncio streams.py:  

blocks.append(block)           # existing
if len(block) < self._limit:   # new
    break                      # new

I have also attached a test file that shows the blocking behavior which is 
alleviated with the above fix.  Finally, I am not sure how to handle a 
situation where the data is exactly equal to the limit and no subsequent data 
is sent.

----------
components: asyncio
files: pty_test.py
messages: 317810
nosy: asvetlov, skorpeo, yselivanov
priority: normal
severity: normal
status: open
title: asyncio Stream Reader Blocks on read when data fetched is less than limit
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file47615/pty_test.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33662>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to