Skip to content

Instantly share code, notes, and snippets.

@saivenkat
Created December 3, 2009 17:20
Show Gist options
  • Select an option

  • Save saivenkat/248347 to your computer and use it in GitHub Desktop.

Select an option

Save saivenkat/248347 to your computer and use it in GitHub Desktop.
Eventlet CouchDb
import StringIO
from eventlet import coros
from eventlet.green import urllib2
class EventCouchDb():
def __init__(self, url):
self.url = url
def fetch(self, url, callback):
callback.write(urllib2.urlopen(url).read())
def get(self, callback):
pool = coros.CoroutinePool(max_size=4)
waiter = pool.execute(self.fetch, self.url, callback)
waiter.wait()
if __name__== '__main__':
resource_url = "http://localhost:5984/unicef-region-data/b0a47e5de8a619ca15f12bb5908d899e"
curl = EventCouchDb(resource_url)
callback = StringIO.StringIO()
curl.get(callback)
print callback.getvalue()
callback.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment