[Python-bugs-list] [ python-Bugs-707074 ] timeouts incompatible w/ line-oriented protocols
SourceForge.net
noreply@sourceforge.net
Sat, 29 Mar 2003 14:55:47 -0800
Bugs item #707074, was opened at 2003-03-20 13:58
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=707074&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
>Assigned to: Skip Montanaro (montanaro)
Summary: timeouts incompatible w/ line-oriented protocols
Initial Comment:
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.
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-29 17:55
Message:
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.
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2003-03-24 12:23
Message:
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
----------------------------------------------------------------------
Comment By: Jack Jansen (jackjansen)
Date: 2003-03-24 05:58
Message:
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.
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2003-03-21 13:02
Message:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=707074&group_id=5470