using gen.task with Tornado for a simple function

后端 未结 1 1753
梦如初夏
梦如初夏 2020-12-14 11:43

Just trying to use the async functions of Tornado - I want to invoke a method from my handler but it keeps telling me that it \"got an unexpected keyword argument \'callback

相关标签:
1条回答
  • 2020-12-14 12:17

    Non-blocking function requires callback, where it pass result.

    class MyHandler(tornado.web.RequestHandler):
    
        @asynchronous
        @gen.engine
        def get(self):
            response = yield gen.Task(self.dosomething, 'argument')
            self.write(response)
            self.finish()
    
        def dosomething(self, myargument, callback):
            return callback(myargument)
    
    0 讨论(0)
提交回复
热议问题