This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncio.StreamReader.readline() lack lines limit optional parameter
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: ajaborsk, gvanrossum, vstinner, yselivanov
Priority: normal Keywords:

Created on 2014-03-03 10:05 by ajaborsk, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg212624 - (view) Author: Alexandre JABORSKA (ajaborsk) Date: 2014-03-03 10:05
This prevent using StreamReader as a normal file object in some circumstances (like http header parsing)
msg212625 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-03-03 10:45
The readline() limit can be set in the StreamReader constructor:
http://docs.python.org/dev/library/asyncio-stream.html#streamreader

Oh, it looks like it is not documented :-(
msg212626 - (view) Author: Alexandre JABORSKA (ajaborsk) Date: 2014-03-03 10:52
Hum... 

It seems to me that the StreamReader() limit parameter is for buffer size while the io.BytesIO.readline() "n" parameter is for maximum number of lines to be retreived, I guess. 

And since the StreamReader().readline() does not accept parameter, it still cannot be used in other modules (like http.client.parse_headers()).
msg212649 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-03-03 18:21
>
> It seems to me that the StreamReader() limit parameter is for buffer size
> while the io.BytesIO.readline() "n" parameter is for maximum number of
> lines to be retreived, I guess.
>

You sound confused. The parameter for io.BytesIO.readline() limits the
number of bytes read in that call. The StreamReader limit parameter also
limits the number of bytes read, in all readline() calls. However, the
effect is different -- if you exceed the limit in io.BytesIO.readline() you
get an unterminated line; if you exceed the limit in
StreamReader.readline(), the call raises an exception.

> And since the StreamReader().readline() does not accept parameter, it
> still cannot be used in other modules (like http.client.parse_headers()).

Since StreamReader.readline() must be used with yield from, you can't use
it in http.client.parse_headers() anyway.
msg212694 - (view) Author: Alexandre JABORSKA (ajaborsk) Date: 2014-03-04 07:35
Well,

  You're right, I'm confused, and I cannot use the http.client.parse_headers(). I made a workaround by reading all lines in a BytesIO and parse this one.

  Anyway, if it not possible to use a file like object with the asyncio module, which is absolutly fantastic (I installed the 3.4RC just for it), a lot a modules will need a rewrite/adaptation to be useable. I guess every module that use any kind of IO is the list : logging, servers, parsers, etc.

  Thanks !

Alexandre
msg212727 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-03-04 15:56
Yes, your whole world will be turned upside-down. However, we have to do it one module at a time -- the approach will be different for each case.
History
Date User Action Args
2022-04-11 14:57:59adminsetgithub: 65040
2014-03-04 15:56:06gvanrossumsetstatus: open -> closed
resolution: wont fix
messages: + msg212727
2014-03-04 07:35:17ajaborsksetmessages: + msg212694
2014-03-03 18:21:30gvanrossumsetmessages: + msg212649
2014-03-03 10:52:54ajaborsksetmessages: + msg212626
2014-03-03 10:45:21vstinnersetnosy: + gvanrossum, vstinner, yselivanov
messages: + msg212625
2014-03-03 10:05:08ajaborskcreate