charveasna / couchdb-python

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

Bad file descriptor error weirdness #201

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
We're seeing a traceback like this:

Traceback (most recent call last):
  File "/home/mjw/src/edison/bidask.py", line 36, in updatedb
    print COUCH_DB.info()
  File "/usr/lib64/python2.7/site-packages/couchdb/client.py", line 563, in info
    _, _, data = self.resource.get_json()
  File "/usr/lib64/python2.7/site-packages/couchdb/http.py", line 393, in get_json
    status, headers, data = self.get(*a, **k)
  File "/usr/lib64/python2.7/site-packages/couchdb/http.py", line 374, in get
    return self._request('GET', path, headers=headers, **params)
  File "/usr/lib64/python2.7/site-packages/couchdb/http.py", line 419, in _request
    credentials=self.credentials)
  File "/usr/lib64/python2.7/site-packages/couchdb/http.py", line 239, in request
    resp = _try_request_with_retries(iter(self.retry_delays))
  File "/usr/lib64/python2.7/site-packages/couchdb/http.py", line 196, in _try_request_with_retries
    return _try_request()
  File "/usr/lib64/python2.7/site-packages/couchdb/http.py", line 216, in _try_request
    conn.endheaders()
  File "/usr/lib64/python2.7/httplib.py", line 937, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python2.7/httplib.py", line 797, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.7/httplib.py", line 773, in send
    self.sock.sendall(data)
  File "/usr/lib64/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 9] Bad file descriptor

However, when we prefix the .info() call by this:

COUCH_DB2 = process.db('eoddata')
print COUCH_DB2.info()

(that is, making a second connection to the same database), it works fine. 
Additionally, this seems to have something to do with daemonization; we're 
daemonizing it using python-daemon, and it only crashes this way when 
daemonized.

Original issue reported on code.google.com by djc.ochtman on 4 Oct 2011 at 2:48

GoogleCodeExporter commented 8 years ago
Figured out the problem: python-daemon, upon daemonization, closes all open 
file descriptors except std*. It is possible to pass in specific file 
descriptors to keep open, but that's rather crappy dance to go through, so it's 
probably easier to setup the database after initializing daemonization.

Original comment by djc.ochtman on 4 Oct 2011 at 2:58