BadYieldError in tornado.gen when using Corduroy couchdb async library
===

I'm trying to use [Corduroy][1] to talk to a CouchDB asynchronously using the python [Tornado Web Server][2].

The code below comes from the [Corduroy guide][3], with a couple of alterations.

    import tornado.web
    from corduroy import Database, NotFound, relax

    people_db = Database('people')
    
    class RelaxedHello(tornado.web.RequestHandler):
        @relax
        def get(self, user_id):
            try:
                doc = yield people_db.get(user_id)
                self.write('hello %s'%(doc['name']))
            except NotFound:
                self.write('hello whoever you are')
            self.finish()
    
    application = tornado.web.Application([
        (r'/hi/([^/]+)', RelaxedHello),
    ]).listen(1920)
    tornado.ioloop.IOLoop.instance().start()

The problem I'm having is that I receive a BadYieldError despite finding the couch document perfectly well. I suspect it's something to do with the tornado.gen module not being set up properly (or something?). Using corduroy without the @relax decorator, and with a callback works fine.

    Traceback (most recent call last):
      File "c:\env\pymeals_tornado\lib\site-packages\tornado\web.py", line 1074, in wrapper
        return method(self, *args, **kwargs)
      File "c:\env\pymeals_tornado\lib\site-packages\corduroy\__init__.py", line 43,  in _r_e_l_a_x_
        return gen.engine(_func_)(*args, **kwargs)
      File "c:\env\pymeals_tornado\lib\site-packages\tornado\gen.py", line 107, in wrapper
        runner.run()
      File "c:\env\pymeals_tornado\lib\site-packages\tornado\gen.py", line 319, in run
        yielded = self.gen.throw(*exc_info)
      File "test.py", line 10, in get
        doc = yield people_db.get(user_id)
    BadYieldError: yielded unknown object <Document 65d936ee54417e46479a908f7a0038ef[2] {name:Colin}>

  [1]: https://github.com/samizdatco/corduroy
  [2]: http://www.tornadoweb.org/
  [3]: http://samizdat.cc/corduroy/guide/