Patches item #1676823, was opened at 2007-03-08 18:32
Message generated for change (Comment added) made by facundobatista
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1676823&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Facundo Batista (facundobatista)
Assigned to: Nobody/Anonymous (nobody)
Summary: Adding timeout to socket.py and httplib.py

Initial Comment:
This is a subset of patch #723312. Like it, adds a NetworkConnection object to 
socket.py, and then use it from 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).

In this patch I only use this new NetworkConnection from httplib, whose 
HTTPConnection class now optionally accepts a timeout.

Beyond the changes in socket.py and httplib.py, this patch also includes 
changes in the docs and new test cases.

----------------------------------------------------------------------

>Comment By: Facundo Batista (facundobatista)
Date: 2007-03-15 15:31

Message:
Logged In: YES 
user_id=752496
Originator: YES

I refactored the patch, now it uses function connect() in socket.py as
specified in my last comment here.

Of course, tests and docs are also updated in the patch.
File Added: timeout.diff

----------------------------------------------------------------------

Comment By: Facundo Batista (facundobatista)
Date: 2007-03-13 13:11

Message:
Logged In: YES 
user_id=752496
Originator: YES

In all the other libraries we can store the timeout, and then make a
single call to socket.py. 

There's no "refactored connect_with_timeout" in socket.py. The
functionality that will be present is one that is repeated several times in
the higher level modules. So, there's no need of a "..._with_timeout" name.


I'll work in a function, in socket.py, called "connect", with this
functionality, and the following signature:

  def connect(address, timeout=None):   # being address == (host, port)
     ...


----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2007-03-12 18:36

Message:
Logged In: YES 
user_id=6380
Originator: NO

I like the idea of refactoring refactoring of the connect() loop, however,
I wonder if a class isn't overkill.  The constructor could just store the
timeout parameter instead of the networkconnection object, and the
connect() method could just call the refactored connect_with_timeout
function passing it the host/port pair and the timeout.  But perhaps
there's a use case I have missed that appears in one of the classes you
haven't patched yet but looked at?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1676823&group_id=5470
_______________________________________________
Patches mailing list
Patches@python.org
http://mail.python.org/mailman/listinfo/patches

Reply via email to