Skip to content

Instantly share code, notes, and snippets.

@minrk
Forked from truemped/issue-10.py
Created May 9, 2011 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minrk/963483 to your computer and use it in GitHub Desktop.
Save minrk/963483 to your computer and use it in GitHub Desktop.
# override ioloop.IOLoop with zmq's IOLoop
import sys
import tornado.ioloop
from zmq.eventloop import ioloop
tornado.ioloop.IOLoop = ioloop.IOLoop
import trombi
loop = ioloop.IOLoop.instance()
# check that tornado's ioloop instance is actually zmq's
assert loop is sys.modules['tornado.ioloop'].IOLoop.instance(), 'IOLoop override failed'
f = open('onemb.zero')
db = trombi.from_uri('http://localhost:5984/test')
def doc_created(doc):
assert not doc.error
doc.attach('1M', f.read(), attach_done)
def attach_done(doc):
print 'attach_done'
assert not doc.error
loop.stop()
db.set({'test': 'doc'}, doc_created)
loop.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment