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

Facundo Batista facundo at taniquetil.com.ar
Wed Mar 21 04:27:23 CET 2007

Alan Kennedy wrote:

>  - Explicitly check that the address passed is a tuple of (string, integer)

It's more probable that a use pass a list of two values, that a host of
two letters as you suggested above...

>  - To raise an exception explaining the parameter expectation when it is not met

Won't be necessary if we take into account the explicit timeout

>  - To require that the user explicitly name the timeout parameter

I already agreed on this, :)

So, as a resume:

 - I'll make "timeout" mandatory
 - The function signature will be:

    create_connection(address[, timeout])

	See that timeout doesn't have a default value, if you include it, it'll
	set the socket timeout, if you don't, the defaultimeout will work.
	The address is a tuple (host, port), as usual

In the code, I'll just make "host, port = address", I don't think it
will be a problem at all. Remember that this function primary use is for
higher level libraries, and that "address" in socket enviroment is
always, always, (host, port).


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

More information about the Python-Dev mailing list