[Python-Dev] Adding timeout to socket.py and httplib.py

Facundo Batista facundo at taniquetil.com.ar
Thu Mar 8 22:44:50 CET 2007


I studied Skip patch, and I think he is in good direction: add a 
NetworkConnection object to socket.py, and then use it from the other
modules.

This NetworkConnection basically does what all the other modules do 
once and again, so no mistery about it (basically calls getaddrinfo
over the received address, and try to open a socket to that address).

I opened a new patch (#1676823) with the changes I propose regarding 
socket.py, because the goal from the two patches are different (my plan
is go with the basic: first the change in socket.py and httplib, and no
in all the other modules at this time). I do not know what to do with
the previous patch (#723312), I guess it'll remain open until all the
other modules get the timeout.

Here're the differences between Skip patch and mine:

- I only left changes regarding httplib and socket modules (both .py, 
  docs, and NEWS).

- I even removed a change in Python-ast.c (regarding __version__), but 
  I don't know what's that for, so please enlighten me (thank you).

- The NetworkConnection won't have a ``get_family`` method, if you need
  the family of the open socket, just ask the socket.

- Added some test cases to test_socket.py regarding attributes, timeout
  and family; and a nice threaded test to actually try the timeout.

- Added tests cases to test_httplib.py

Feel free to review the patch, and commit it if you want (or tell me to
do it after the review, it's just a command for me).

Regards,

-- 
.   Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/




More information about the Python-Dev mailing list