Looks like a bug to me. Ignoring an explicitly-set timeout can't be OK.
> Also, it seems like some tests were built around this behavior.
This clearly shows the requirement, for any kind of test-driven
development, to write the tests *first*, instead of merely using them to
document (un)intended behavior.
--
-- Matthias Urlichs
On Tue, Apr 17, 2012 at 8:56 PM, Colin Marc <coli...@gmail.com> wrote:
> -In gevent, read() blocks until the client disconnects (I was testing with
> telnet), and reports that the read data was '' (an empty string)
> -Without gevent, read() raises a socket.timeout after a second
It's not intended. Sometime ago we had dup() inheriting timeout.
However, that was wrong and we fixed that. The makefile() used dup()
and thus stopped inheriting timeout as well. No one noticed until now.
Thanks for the report!
Fixed here: https://bitbucket.org/denis/gevent/changeset/65968cf1baa9
BTW, the reason nobody noticed it before is probably the fact that
fileobject is quite useless in the presence of socket timeouts as it
loses some of the buffered data in case of a timeout firing. The only
sensible response to timeout firing therefore is to close the
connection.
> Also, it seems like some tests were built around this behavior. For example,
> test__server.TestDefaultSpawn.test_error_in_spawn. That test raises an
> error, then asserts that an empty string was read from the socket.
I'm not sure how this test is related to the issue at hand. Could you elaborate?
Cheers,
Denis.
I think read() returns '' in this case because the server closed the
connection. You can verify that by disabling socket timeouts
altogether. It'll still return ''.