[Patches] [ python-Patches-723312 ] ability to pass a timeout to underlying socket

SourceForge.net noreply at sourceforge.net
Sat Feb 10 19:57:33 CET 2007


Patches item #723312, was opened at 2003-04-17 14:03
Message generated for change (Comment added) made by montanaro
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: Skip Montanaro (montanaro)
Date: 2007-02-10 12: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 11: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-09-30 22: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 09: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 07: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-20 18: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