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) *  |
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) *  |
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) *  |
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. |
|
|