This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: add socket.timeout exception
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: rhettinger, rthalley
Priority: normal Keywords: patch

Created on 2003-06-25 04:55 by rthalley, last changed 2022-04-10 16:09 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch rthalley, 2003-06-25 04:55 socket.timeout patch
doc_patch rthalley, 2003-06-29 03:49
test_patch rthalley, 2003-06-29 04:14 some simple unit tests
test_patch rthalley, 2003-06-29 04:17 unit test patch
Messages (13)
msg44099 - (view) Author: Bob Halley (rthalley) Date: 2003-06-25 04:55
Here's a patch for bug 758239.  It adds a
socket.timeout exception to the socket module, and
raises that exception whenever a timeout occurs.

I have tried to use a light hand, making only
(hopefully) correctness-preserving edits as opposed to
attempting any more radical restructuring of the way
internal_select() is used.

The diff is against the CVS current version of
socketmodule.c.

I have tested this by hand on my x86 Red Hat 9 system,
and it works correctly.  I have also done "make test"
and had no failures related to the socket module
(though I too am seeing a failure of test_strptime).

I do not have a Windows build environment available to
me, so I have not tested my changes on Windows.

/Bob
msg44100 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-06-28 20:19
Logged In: YES 
user_id=80475

I haven't yet been able to review this in detail.
Is a simpler implementation possible (changing socket.error 
to socket.timeout and changing nothing else)?
msg44101 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-06-28 20:21
Logged In: YES 
user_id=80475

On a separate note, can you email to me the traceback from 
the failure on strptime?  I would like to fix it but it won't fail 
for me on Windows.
msg44102 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-06-28 20:28
Logged In: YES 
user_id=80475

If you're up to it, please also submit a patch for the docs and 
unittests.  The next beta goes out in the morning so we only 
have a short time to get this done and make it perfect.

Please also do a second desk check of your work, it is 
important that we don't break anything in this critical 
module.
msg44103 - (view) Author: Bob Halley (rthalley) Date: 2003-06-29 02:58
Logged In: YES 
user_id=671513

I don't think the patch can be much simpler than it is.  We
can't raise the exception inside of internal_select(),
because we don't have the interpreter lock then.

It's a good thing that we do not attempt the I/O after we
know we have a timeout, since we don't want to actually do
the I/O have it succeed after all, and then return "timeout".

The other changes make sure result variables from the I/O
are always initialized, to keep the compiler from issuing
warnings.  (There's no chance we'd actually use one of those
variables in the timeout case, but some compilers can't
figure that out.)

I'll recheck things and post a followup message.  I'll see
what I can do about docs + unittests, though timezones
aren't working in our favor at the moment (I'm in Australia
right now).
msg44104 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-06-29 03:04
Logged In: YES 
user_id=80475

Guido has given me the go ahead to put it in eventhough we 
haven't had a chance for thorough review.  I've looked at the 
code again and agree it cannot be further simplified -- that 
was just wishful thinking.

The best thing to do right now is for you to desk check your 
patch one more time.  I'll work on the doc update and 
newsitem.  After your desk check, a couple of unittests would 
be very helpful.

msg44105 - (view) Author: Bob Halley (rthalley) Date: 2003-06-29 03:50
Logged In: YES 
user_id=671513

OK, I'll write some unit tests now, and do another check of
the code.  I uploaded a doc patch since I'd already done it
before I read your reply :)
msg44106 - (view) Author: Bob Halley (rthalley) Date: 2003-06-29 04:14
Logged In: YES 
user_id=671513

Here is a unit test patch
msg44107 - (view) Author: Bob Halley (rthalley) Date: 2003-06-29 04:19
Logged In: YES 
user_id=671513

Use the later unit test patch; the first one had a
cut-and-paste error (mentioned "UDP" in the error messages
for TCP failures)
msg44108 - (view) Author: Bob Halley (rthalley) Date: 2003-06-29 04:31
Logged In: YES 
user_id=671513

OK, I have reviewed the changes again and they look good to
me.  My only regret is that I don't have a windows compiler
so I can't test on windows.
I think the changes should work fine on windows, however,
since the only place they differ from POSIX is
internal_connect(), and that should be OK.
 
msg44109 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-06-29 04:38
Logged In: YES 
user_id=80475

I've got it from here (including testing the windows 
environment and checking the doc markup).
msg44110 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-06-29 04:44
Logged In: YES 
user_id=80475

Please confirm that using a call to setdefaulttimeout() with 
also enable socket.timeout.
msg44111 - (view) Author: Bob Halley (rthalley) Date: 2003-06-29 06:16
Logged In: YES 
user_id=671513

Confirmed.  If I set a default timeout > 0.0 seconds, the
socket.timeout exception happens as expected.  If I set the
default timeout to 0.0 or to None, socket.timeout is not
raised, again as expected.
History
Date User Action Args
2022-04-10 16:09:25adminsetgithub: 38707
2003-06-25 04:55:42rthalleycreate