On 2015-09-03 2:01 PM, Yury Selivanov wrote:
On 2015-09-03 11:04 AM, Victor Stinner wrote:
Hi,

I proposed a patch to add timeout to StreamReader read methods:
http://bugs.python.org/issue23236

I'm +1, but there are some subtleties that I want to better
understand:


The idea is to reset the timeout each time we receive new data. It is
less strict than wait(read(), timeout) which restricts the total
duration. The subtle risk is that a server can "DoS" a client by
sending slowly the reply by packets of a single byte every N seconds.

But you usually don't use plain read() calls. In almost all
protocols you either use readexactly() or readline(), this
way you don't need to do buffering yourself.

In which case using wait(readexactly()) or wait(readline())
is safe, right?


But you want combine the two timeouts. For example,
wait(readline(timeout=5.0), 60.0) fails if the server takes longer
than 5 seconds to send data or if the server doesn't send a newline
before 60 seconds.

I'm not sure I understand the above.


Never mind, Victor has explained me the difference.  Now I think
that we can't name this new parameter 'timeout' -- it'd be too
confusing.

Yury

Reply via email to