[Python-Dev] I vote to reject: Adding timeout to socket.py and httplib.py.
python-dev at alan.kennedy.name
Wed Mar 21 10:59:51 CET 2007
> Remember that this function primary use is for
> higher level libraries
Yes, I see that clearly now.
But remember that by adding a new function to the socket module to
support httplib et al, you are also adding a function to the socket
module that will be used directly by end users.
I vote to reject this patch.
The underlying problem it is trying to address is that
httplib.HTTPConnection objects do not support timeouts.
But solving that problem by moving the functionality of the
HTTPConnection.connect() method inside the socket module as a
standalone function is the *wrong* solution.
The proposed new function does not belong in the socket module. In
contrast to all of the other socket creation and management
functionality in the socket module, the new function does not handle
Also, the new functions' use-case is too restricted, to client
connections with a positive timeout: this functionality is trivially
available using existing functionality, e.g.
mysock = socket(AF_INET, SOCK_STREAM)
mysocket.connect( (host, port) )
In contrast to the new function, the existing functionality in the
socket module is much more general, and much better designed to handle
the wide range of situations in which sockets are used. Socket APIs
are hard to do right because sockets are complex and hard to do right.
The problem the patch seeks to fix is is in httplib; the problem
should be fixed in httplib.
I recommend modifying the patch to remove *all* proposed changes to
the socket module. Instead, the patch should restrict itself to fixing
the httplib module.
More information about the Python-Dev