[Patches] [ python-Patches-723312 ] ability to pass a timeout to underlying socket
SourceForge.net
noreply at sourceforge.net
Sun Feb 25 17:43:25 CET 2007
Patches item #723312, was opened at 2003-04-17 20:03
Message generated for change (Comment added) made by jjlee
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=723312&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: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Matthew Russell (mattruss)
Assigned to: Skip Montanaro (montanaro)
Summary: ability to pass a timeout to underlying socket
Initial Comment:
this patch superceeds an earlier one i posted (#714592)
- a bit *too* enthusiastic am afraid (sorry!)
classes in modules such as httplib, ftpplib do not
currently allow an easy way to take advantage of the
new socket timeout feature in 2.3.
This patch provides that abilty though one additonal
class in socket.py ( socket.NetworkConnection ) and
accompying test in test_socket.py (basic though the
test is :-s )
As an extra benifit, the patch removes duplicate code,
as each connect method in the main class of most
modules (FTP, HTTPConnection, Telnet, POP3 etc) are
copies of each other.
The modules that use sockets are:
* ftplib
* httplib
* telnetlib
* poplib
* urllib
* imaplib
* nntplib
* xmlrpclib
Of these I have only been able to easily refactor
NetworkConnection into httplib, ftplib, telnetllib,
poplib and smtplib.
I did look to see if there were any unittests for
theese modules in .Lib/test but found none (? - I
appologise if there are some, i am new to the library
tests)
I did however check that the test() [like] methods at
the bottom of each of the afore mentioned modules worked.
thanks for your advice again Skip :o)
Matt
----------------------------------------------------------------------
Comment By: John J Lee (jjlee)
Date: 2007-02-25 16:43
Message:
Logged In: YES
user_id=261020
Originator: NO
Looks good. I can't write tests right now, but just reading the code:
I don't see a path in socket.NetworkConnection.connect() in which "if sock
is None" is ever true. And what happens if creating a new socket object
raises an exception (e.g. if too many file descriptors are open)? Then
socket may be undefined, and will certainly not be None. I think it needs
a sock = None before the loop, and also in the except: suite immediately
before the continue statement.
Some debug output in httplib has been lost (and maybe in the other
modules). This is really very useful, so I think it should be preserved.
In ftplib, FTP.makeport() should also use socket.NetworkConnection .
PEP 8 nits:
Use of thisStyleOfName, e.g. networkConnection
Use of two-argument raise, e.g. raise socket.error, msg -- replace with
raise socket.error(msg)
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2007-02-11 18:14
Message:
Logged In: YES
user_id=44345
Originator: NO
Jeez, I can be an idiot sometimes... Working on two patches in the same
sandbox.
File Added: timeout.diff
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2007-02-11 18:11
Message:
Logged In: YES
user_id=44345
Originator: NO
*argh* one minor tweak too many...
File Added: timeout.diff
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2007-02-11 16:24
Message:
Logged In: YES
user_id=44345
Originator: NO
New patch with minor tweaks. Added doc changes.
File Added: timeout.diff
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2007-02-10 18:57
Message:
Logged In: YES
user_id=44345
Originator: NO
Here's an updated patch. Tests pass. There's no documentation for
socket.NetworkConnection or for the API changes to smtplib, httplib,
telnetlib, poplib or ftplib.
File Added: timeout.diff
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2006-04-14 17:09
Message:
Logged In: YES
user_id=21627
mattruss, are you interested in forward-porting it to 2.5?
If that gets done before the beta release, please assign it
to me for review.
----------------------------------------------------------------------
Comment By: Anthony Baxter (anthonybaxter)
Date: 2005-10-01 04:39
Message:
Logged In: YES
user_id=29957
Just a quick note - this patch might be accepted for 2.5,
but it's not suitable for 2.4.x - once a major release is
done, subsequent minor releases (2.3.x, 2.4.x) are
bugfix-only. No new features are acceptable. For more on
this, see http://www.python.org/peps/pep-0006.html
----------------------------------------------------------------------
Comment By: zeidler (zeidler)
Date: 2005-09-28 15:22
Message:
Logged In: YES
user_id=1082576
perhaps to add a little emphasis: i'd really like to see
that patch included into one of the next releases too. i
was just going to submit my own, much much simpler version
of adding a socket timeout in httplib.py, but matt's patch
is a much better way to do this...
we're using xml-rpc a lot over here, and the default
timeouts are just way too long to keep up a decent user
interaction in case of server problems. so, we'd really
appreciate this becoming part of the distro! ;)
thanks & good job matt,
andi
----------------------------------------------------------------------
Comment By: Grégoire Weber (gregweb)
Date: 2005-01-12 13:52
Message:
Logged In: YES
user_id=812601
Just lobbying:
It would be nice to have that on board in futire python
versions.
Would this be possible in python 2.4.1?
I need timeouts for xmlrpclib and subclassed
xmlrpclib.Transport for my needs.
But nevertheless it would be nice to have that in python 2.4.1.
Thanks!
Gregoire
----------------------------------------------------------------------
Comment By: Matthew Russell (mattruss)
Date: 2003-04-21 00:20
Message:
Logged In: YES
user_id=737261
Errata:
i forgot to mention urlllib2 as modules affected.
the line above starting "The modules that use sockets are: "
should really read: "classes in the modules stated below
would benifit from the ability pass timeouts:"
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=723312&group_id=5470
More information about the Patches
mailing list