[Python-Dev] Socket timeout patch

Bernard Yue bernie@3captus.com
Fri, 07 Jun 2002 13:17:52 -0600


[Guido]
> Remaining issues:
> 
> - A test suite.  There's no decent test suite for the timeout code.
>   The file test_timeout.py doesn't test the functionality (as I
>   discovered when the test succeeded while I had several blunders 
>   in the select code that made everything always time out).

[Michael]
>   Er, hopefully Bernard is still watching this thread as he wrote
> the test_timeout.py. He's been pretty quiet though as of late... I'm
> willing to rewrite the tests if he doesn't have the time. 
>
>   I think the tests should follow the same pattern as the
> test_socket.py.  While adding my regression tests, I noted that the
> general socket test suite could use some re-writing but I didn't feel
> it appropriate to tackle it at that point. Perhaps a next patch?

Looks like I have missed the war, folks!  I will work on the test 
suite.  The orginal test_timeout.py is incomplete.  I actually had 
problem when writing test case for accept(), using blocking() and 
makefile().  Guido, you are right on the point, the test suite 
should work without the timeout code as well.  If I've done that ...

As for the scope of the test suite, I would prefer to focus on socket 
timeout test for now.  Though there will be overlapping test for socket 
timeout test and socket test, we can always merge it later.


[Guido]
> - Cross-platform testing.  It's possible that the cleanup broke things
>   on some platforms, or that select() doesn't work the same way.  I
>   can only test on Windows and Linux; there is code specific to OS/2
>   and RISCOS in the module too.

[Michael]
>   This was a concern from the beginning but we had some chat on the
> dev list and concluded that any system supporting sockets has to
> support select or some equivalent (hence the initial reason for using
> the select module, although I agree it was expensive).

I now have Visual C++ version 6, but still limited to Windows and 
Linux.  I think once we are done with this two platform, we can ask 
people to run the test on other platform.  But I agreed with Michael
that using python select module put us on the safer side.


[Guido]
> - Should sock.settimeout(0.0) mean the same as sock.setblocking(0)?

> OTOH, a timeout of 0 behaves very similar to nonblocking mode --
> similar enough that a program that uses setblocking(0) would 
> probably also work when using settimeout(0).  I kind of like the 
> idea of having only a single internal flag value, sock_timeout, 
> rather than two (sock_timeout and sock_blocking).

Agree.

[Guido]
> - The original timeout socket code (in Python) by Tim O'Malley had a
>  global timeout which you could set so that *all* sockets
>  *automatically* had their timeout set.  This is nice if you want it
>  to affect library modules like urllib or ftplib.  That feature is
>  currently missing.  Should we add it?  (I have some concerns about
>  it, in that it might break other code -- and it doesn't seem wise to
>  do this for server-end sockets in general.  But it's a nice hack for
>  smaller programs.)

Steve Holden and M.-A. Lemburg have spoken.


Bernie