Python error
When trying to set or get an object the operation itself seems to work (new documents appear in the DB on set at least) but I get the following exception printout every time:
< pre >
all_players_bucket.set(player['id'], 0, 0, json.dumps(player))
File "/Users/mbhamala/dev/feral/src/tanks/cage/eggs/couchbase-0.8.0-py2.7.egg/couchbase/client.py", line 222, in set
return self.mc_client.set(key, expiration, flags, value)
File "/Users/mbhamala/dev/feral/src/tanks/cage/eggs/couchbase-0.8.0-py2.7.egg/couchbase/couchbaseclient.py", line 556, in set
return self._respond(item, event)
File "/Users/mbhamala/dev/feral/src/tanks/cage/eggs/couchbase-0.8.0-py2.7.egg/couchbase/couchbaseclient.py", line 512, in _respond
raise item["response"]["error"]
error: cannot switch to a different thread
"
My server uses gevent and I'm wondering if this exception is related to gevent.
For this test case I create a new Couchbase client on every request with so there shouldn't be multiple greenlets using the same connection.
test_client = Couchbase('localhost:8091',
username='Administrator',
password='password')Using Python couchbase 0.8.0 with requests 0.14.0
Anyone experienced anything similar?
- Mac OS X 10.7.4
- couchbase-server-community_x86_64_2.0.0
- requests 0.14.0
- python couchbase driver 0.8.0
- gevent 1.0rc1
I'm running a server built on gevent and if I had to guess I would say that either the streaming_thread or dispatcher_thread in couchbaseclient.py doesn't interact well with the gevent internals. I'm not very familiar with gevent and thread interoperability but my understanding is that mixing greenlets and threads may cause issues.
Mongo's python client pymongo has solved this by implementing gevent support into the driver: http://api.mongodb.org/python/current/examples/gevent.html
Yes.
Make sure to put this at the begining of your code:
from gevent import monkey monkey.patch_all()
We have couchbase-python 0.8.0 with last trunk of gevent working faultlessly
Awesome, thanks!
I had only monkey patched socket and missed patching all else.
Hello
This is the first time that I see this error. Could you please give us your environment information to help us reproduce the issue?
Couchbase Server, OS, ..., versions..
Thanks
Tug
Tug
@tgrall