lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

"socket.error: [Errno 32] Broken pipe" when uploading an attachment using auth #68

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This is occurring using:

CouchDB-Python SVN r138
CouchDB SVN r756688

(both latest at time of writing)

I can only seem to reproduce this when running it on the same machine as
the CouchDB instance.  See attached for a minimal reproducible test case.

$ python2.6 test.py 
Traceback (most recent call last):
  File "test.py", line 39, in <module>
    db.put_attachment(db['python_auth_test_doc'], '1'*1000000, 'test.txt')
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/couchdb/client.py",
line 453, in put_attachment
    }, rev=doc['_rev'])
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/couchdb/client.py",
line 865, in put
    **params)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/couchdb/client.py",
line 891, in _request
    resp, data = _make_request()
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/couchdb/client.py",
line 886, in _make_request
    body=body, headers=headers)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/httplib2/__init__.py",
line 1089, in request
    (response, content) = self._request(conn, authority, uri, request_uri,
method, body, headers, redirections, cachekey)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/httplib2/__init__.py",
line 881, in _request
    (response, content) = self._conn_request(conn, request_uri, method,
body, headers)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/httplib2/__init__.py",
line 850, in _conn_request
    conn.request(method, request_uri, body, headers)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httpl
ib.py",
line 880, in request
    self._send_request(method, url, body, headers)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httpl
ib.py",
line 914, in _send_request
    self.send(body)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httpl
ib.py",
line 719, in send
    self.sock.sendall(str)
  File "<string>", line 1, in sendall
socket.error: [Errno 32] Broken pipe

Original issue reported on code.google.com by jason.da...@gmail.com on 20 Mar 2009 at 11:58

Attachments:

GoogleCodeExporter commented 8 years ago
After digging deeper, it seems there may be a bug in Python's httplib or in 
httplib2,
which only occurs if the server closes the socket before the client has had a 
chance
to send the request body.  This is the case for CouchDB - once it has read the
request headers it immediately attempts auth, and it

I think this is acceptable (and HTTP-compliant) behaviour.  It just means that 
even
if the httplib/httplib2 client library gets a broken pipe error when writing the
request body, it should check for a response first before propagating the error.

I am working on finding a workaround or a patch for httplib/httplib2, watch 
this space.

Original comment by jason.da...@gmail.com on 21 Mar 2009 at 1:19

GoogleCodeExporter commented 8 years ago
Just filed a bug in the Python bug tracker for httplib: 
http://bugs.python.org/issue5542

I also have a patch for httplib2.

Original comment by jason.da...@gmail.com on 23 Mar 2009 at 9:30

GoogleCodeExporter commented 8 years ago
Patch for httplib2 posted to: 
http://code.google.com/p/httplib2/issues/detail?id=51

Original comment by jason.da...@gmail.com on 23 Mar 2009 at 9:40

GoogleCodeExporter commented 8 years ago
Jason, can I correctly conclude that we probably shouldn't do anything to fix 
this in
CouchDB-python?

Original comment by djc.ochtman on 14 Dec 2009 at 11:04

GoogleCodeExporter commented 8 years ago
Closing as WorksForMe, feel free to re-open.

Original comment by djc.ochtman on 24 Dec 2009 at 12:57