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

Python SDK real world use

2 replies [Last post]
  • Login or register to post comments
Tue, 01/01/2013 - 14:23
stowywowy
Offline
Joined: 01/01/2013
Groups: None

I'm trying to establish the correct method of using the Python SDK (as it stands right now) in a WSGI based application (Flask).

Each new connection to the cluster (single member running on localhost) takes over a second to establish. This means I must leave the connection open, which can then be reused by subsequent requests. I assume this is bad, as there are resources being left open after the WSGI process / thread dies (unless this is the rest client only?). I'm using the unified client at the moment.

I don't see an alternative to leaving this open right now (the unified client doesn't have a close method anyway). Any suggestions on the correct approach?

Top
  • Login or register to post comments
Fri, 01/04/2013 - 00:09
ingenthr
Offline
Joined: 03/16/2010
Groups:

I can think of two approaches.

The best approach would be to keep this persistent across requests, and create it if it doesn't exist. Looking about a bit, I found one reference that says it should be possible to have this as a global dict[1]. This way, it would be around for the life of the process, and all of the resources would be collected after it's been used.

The second approach might be to implement a simple connection pool, as that seems to be a common recommendation I found with flask and django[2][3].

Well, there is a third approach, and that's that client side moxi can offload this. In that way, it's similar to pgpool or mysql proxy. The rest client and memcached client can be configured against a moxi running locally.

Longer term, we'll look to put something together for this, but we don't have anything at the moment. I'm interested in it personally.

Please let me know if you're able to get any further with the global approach.

1. http://stackoverflow.com/questions/6729639/how-to-share-db-connection-li...
2. http://dumpz.org/67550/
2. http://stackoverflow.com/questions/6688413/how-to-preserve-database-conn...

Top
  • Login or register to post comments
Sun, 03/10/2013 - 23:22
sayap
Offline
Joined: 03/06/2013
Groups: None

The global approach only works if the SDK is thread-safe, right? I couldn't find any info to indicate whether the python SDK is thread-safe.

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