Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 2.0

Python error

4 replies [Last post]
  • Login or register to post comments
Wed, 12/12/2012 - 17:00
sctrbrain
Offline
Joined: 12/12/2012
Groups: None

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?

Top
  • Login or register to post comments
Thu, 12/13/2012 - 05:53
tgrall
Offline
Joined: 09/05/2012
Groups: None

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

Top
  • Login or register to post comments
Thu, 12/13/2012 - 06:09
sctrbrain
Offline
Joined: 12/12/2012
Groups: None

- 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

Top
  • Login or register to post comments
Fri, 12/14/2012 - 02:06
conekia
Offline
Joined: 12/14/2012
Groups: None

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

Top
  • Login or register to post comments
Fri, 12/14/2012 - 03:15
sctrbrain
Offline
Joined: 12/12/2012
Groups: None

Awesome, thanks!

I had only monkey patched socket and missed patching all else.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker