Using python generators at the same time as Tornado

I have a tornado server which I am ok with running synchronously. One of the callback handlers calls a method in another module which internally uses generators to iterate over results, using the yield keyword.

Calling the function directly works however triggering it from the tornado server seems to stop execution as soon as it reaches the yield keyword.

Is it possible to use both? This is in a way the opposite question to Using a simple python generator as a co-routine in a Tornado async handler?

Calling code from the tornado end eg:

class SearchHandler(tornado.web.RequestHandler):
    # @tornado.web.asynchronous
    # @gen.coroutine
    def get(self): 
        self.write(ice.getStructs(collapseArguments(self.request.arguments)))

I don't mind it running asynchronously, but don't need to convert the whole function to be a generator

链接地址: http://www.djcxy.com/p/27854.html

上一篇: 无法使用self.finish()完成Tornado中的RequestHandler

下一篇: 与Tornado同时使用Python生成器