[issue14562] urllib2 maybe blocks too long
New submission from Anrs Hu : If HTTP URL response's Transfer-Encoding is 'Chunked', then the urllib2.urlopen(URL).readline() will block until there're enough 8192 bytes, even though the first chunk is just a line. Every chunks should be processed as soon as posible, so the readline() behavior should read a line and return immediately, rather than read 8K data to buffer and look up a line from the buffer. -- components: Library (Lib) messages: 158124 nosy: Anrs.Hu priority: normal severity: normal status: open title: urllib2 maybe blocks too long type: behavior versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue14562> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14562] urllib2 maybe blocks too long with small chunks
Anrs Hu added the comment: Okay, there's a test case of web.py: Server codes are following: import web class index(object): def GET(self): yield 'hello\n' yield 'world\n' time.sleep(60) client is Python interpreter >>> resp = urllib.urlopen(URL) >>> resp.readline() # will be 'hello' >>> resp.readline() # will be 'world' >>> resp.readline() # huh, it's blocked, and we to agree with it. >>> # but to use urllib2 will another behavor. >>> urllib2.urlopen(URL).readline() # huh, it's blocked even if 'hello' and >>> 'world' returned yet. Because urllib2 uses a 8KiB buffer on >>> socket._fileobjece within urllib2.py, it read 8K data to buffer first. -- ___ Python tracker <http://bugs.python.org/issue14562> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com