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: timeouts incompatible w/ line-oriented protocols
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: skip.montanaro Nosy List: gvanrossum, jackjansen, nnorwitz, skip.montanaro
Priority: normal Keywords:

Created on 2003-03-20 18:58 by skip.montanaro, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
socket.diff skip.montanaro, 2003-03-21 18:02
Messages (7)
msg15217 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-03-20 18:58
I've come to the conclusion that, as written, the higher level line-
oriented protocols which use the socket library (httplib, ftplib,
xmlrpclib, etc) won't work with socket timeouts.  They generally do
something like:

    self.file = self.sock.makefile('rb')

then use file methods to send and receive data on the socket.

Alas, the socket docs state:

Timeout mode internally sets the socket in non-blocking mode.
The blocking and timeout modes are shared between file descriptors
and socket objects that refer to the same network endpoint.  A
consequence of this is that file objects returned by the makefile()
method should only be used when the socket is in blocking mode; in
timeout or non-blocking mode file operations that cannot be
completed immediately will fail.  

I view this state of affairs as a bug which should be fixed at some
point, as these higher level protocol modules are probably the 
predominant way sockets get used in Python programs.
msg15218 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-03-21 18:02
Logged In: YES 
user_id=44345

The attached simple patch to socket.py seems to do the trick.  No tests
fail as a result.  The new test_urllibnet test case fails on Mac OS X
without the patch and succeeds with the patch.
msg15219 - (view) Author: Jack Jansen (jackjansen) * (Python committer) Date: 2003-03-24 10:58
Logged In: YES 
user_id=45365

If this patch is accepted: may I request it be done soon? Changes like this often affect how things work on MacOS9 (IOW: break things on MacOS9:-), and in general changing the makefile() semantics on all non-windows platforms is something that may turn up hidden bugs, so I don't think we want this in as a last-second mod before 2.3b1 goes out.
msg15220 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-03-24 17:23
Logged In: YES 
user_id=44345

Jack, Any chance you can simply apply it to the source and see how it goes
on MacOS9? -Skip
msg15221 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-03-29 22:55
Logged In: YES 
user_id=33168

This works for me on linux.  I don't know if there's any
issue wrt to removing _needwrapper.  Perhaps it should be
checked in and see if anyone complains?  I'm not sure who
else should review this patch.
msg15222 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-03-30 05:10
Logged In: YES 
user_id=44345

Okay, checked in and closed.  Let's see who screams.

Lib/socket.py 1.36
Lib/test/test_urllibnet.py 1.1
Misc/NEWS 1.705
msg15223 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-04-11 20:38
Logged In: YES 
user_id=6380

Not me. I didn't even notice this was checked in! Good job.
History
Date User Action Args
2022-04-10 16:07:48adminsetgithub: 38191
2003-03-20 18:58:56skip.montanarocreate