[Patches] [ python-Patches-555085 ] timeout socket implementation
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 18 Jul 2002 10:11:46 -0700
Patches item #555085, was opened at 2002-05-12 08:11
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=555085&group_id=5470
Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: Accepted
>Priority: 4
Submitted By: Michael Gilfix (mgilfix)
Assigned to: Guido van Rossum (gvanrossum)
Summary: timeout socket implementation
Initial Comment:
This implements bug #457114 and implements timed socket
operations. If a timeout is set and the timeout period
elaspes before the socket operation has finished, a
socket.error exception is thrown.
This patch integrates the functionality at two levels:
the timeout capability is integrated at the C level in
socketmodule.c. Socket.py was also modified to update
fileobject creation on a win platform to handle the
case of the underlying socket throwing an exception.
The tex documentation was also updated and a new
regression unit was provided as test_timeout.py.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-07-18 13:11
Message:
Logged In: YES
user_id=6380
The default timeout is now implemented in CVS.
There's a bug report from Andrew Macintyre (unfortunately on
python-dev) about test_socket.py failures on FreeBSD. I'll
try to keep an eye on that, so this patch *still* stays
open. Also, Bernie has promised some changes that I haven't
received yet and the details of which I don't recall (sorry
:-( ).
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-06-07 21:47
Message:
Logged In: YES
user_id=6380
Keeping this open as a reminder of things still to finish.
Most is in the python-dev discussion; Michael Gilfix and
Bernard Yue have offered to produce more patches.
One feature we definitely want is a way to specify a timeout
to be applied to all new sockets.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-06-06 17:11
Message:
Logged In: YES
user_id=6380
Thanks for the new version! I've checked this in. I made
considerable changes; the following is feedback but you
don't need to respond because I've addressed all these in
the checked-in code!
- Thanks for the cleanup of some non-standard formatting.
However, it's better not to do this so the diffs don't show
changes that are unrelated to the timeout patch.
- You are still importing the select module instead of
calling select() directly. I really think you should do the
latter -- the select module has an enormous overhead (it
allocates several large lists on the heap).
- Instead of explicitly testing the argument to settimeout
for being a float, int or long, you should simply call
PyFloat_AsDouble and handle the error; if someone passes
another object that implements __float__ that should be
acceptable.
- gettimeout() returns sock_timeout without checking if it
is NULL. It can be NULL when a socket object is never
initialized. E.g. I can do this:
>>> from socket import *
>>> s = socket.__new__(socket)
>>> s.gettimeout()
which gives me a segfault. There are probably other places
where this is assumed.
- I addressed the latter two issues by making sock_timeout a
double, whose value is < 0.0 when no timeout is set.
----------------------------------------------------------------------
Comment By: Michael Gilfix (mgilfix)
Date: 2002-06-05 18:23
Message:
Logged In: YES
user_id=116038
I've addressed all the issues brought up by Guido. The 2nd
version of the patch is attached here. In this version, I've
modified test_socket.py to include tests for the _fileobject
class in socket.py that was modified by this patch.
_fileobject needed to be modified so that data would not be
lost when the underlying socket threw an expection (data was
no longer accumulated in local variables). The tests for the
_fileobject class succeed on older versions of python
(tested 2.1.3) and pass on the newer version of python.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-05-23 16:18
Message:
Logged In: YES
user_id=6380
For a detailed review, see
http://mail.python.org/pipermail/python-dev/2002-May/024340.html
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=555085&group_id=5470