[issue23236] asyncio: add timeout to StreamReader read methods
STINNER Victor
report at bugs.python.org
Wed Jan 14 01:49:35 CET 2015
STINNER Victor added the comment:
Copy of the feature requets by Guido van Rossum:
https://code.google.com/p/tulip/issues/detail?id=96
Often you want to stop servicing (or using) a connection when there is no activity in a given time. You can do this by wrapping all your read calls in wait_for(), but a single readline() or readexactly() call may do multiple I/O operations and typically you want to reset the timeout whenever you receive some more bytes. So it makes more sense to either add the timeout to the various read*() calls, or even to (optionally) set it in the constructor, so that the class can implement a more subtle timeout algorithm.
I could imagine an overall timeout too, and possibly even something that gives up if the bandwidth goes below a threshold, to avoid waiting forever on a huge download.
(For StreamWriter I think it's sufficient to call wait_for(w.drain()), so I think this only applies to StreamReader.)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23236>
_______________________________________
More information about the Python-bugs-list
mailing list