classification
Title: xmlrpc: Transport.request() should also catch socket.error(EPIPE)
Type: Stage:
Components: Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: vstinner
Priority: normal Keywords: patch

Created on 2010-06-18 22:32 by vstinner, last changed 2010-07-24 02:52 by vstinner. This issue is now closed.

Files
File name Uploaded Description Edit
xmlrpc_request_epipe.patch vstinner, 2010-06-18 22:32
Messages (3)
msg108146 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-18 22:32
Since Python 2.7 / 3.2, httplib supports HTTP(S)/1.1 (keep-alive). This version of HTTP is much faster because the connection is kept between two requests. I'm using it with XML-RPC + SSL (M2Crypto). It works nice.

My problem is when the server closes the connection (eg. the server restarts). If I send a small (XML-RPC) request, sending the request works (I don't understand why, maybe because of a buffer somewhere), but getting the response raises a BadStatusLine because the response is empty (0 byte). If I send a big (XML-RPC) request, sending the request fails with a SSLError(EPIPE, '...') and Transport.request() doesn't retry with a new connection.

I patched my copy of M2Crypto to ensure that SSLError inherits from socket.error, but it's not enough: Transport.request() only catchs errno.ECONNRESET and errno.ECONNABORTED socket errors.

Attached patch catchs also errno.EPIPE. This error is received on sending to the socket whereas the server closed the socket.
msg108147 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-18 22:54
See also r70643 (from issue #5542): "Remove special logic that closes HTTPConnection socket on EPIPE.

If the socket is closed, the client has no chance to read the response
from the server.  EPIPE means that it isn't possible to write more
data from the socket, but not that it is impossible to read."

This commit didn't updated the following comment. I think that it should be fixed (maybe removed?) because the socket is no more closed on broken pipe error.

# send the data to the server. if we get a broken pipe, then close
# the socket. we want to reconnect when somebody tries to send again.
msg111422 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-07-24 02:52
I fixed the bug in 2.7 (r83123) and 3.2 (r83120).
History
Date User Action Args
2010-07-24 02:52:23vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg111422
2010-06-18 22:54:08vstinnersetmessages: + msg108147
2010-06-18 22:32:25vstinnercreate