2014-05-14 20 views
4

我目前使用的软件堆栈为:Tornado(Websockethandler)+ Celery(任务管理器)+ RabbitMQ(amqp)+ Redis作为后端。如何在龙卷风中启动一个websocket请求的芹菜任务?

但是我不能将龙卷风和芹菜集成到websocket请求中。我们可以有一些指针/例子吗?

注意我已经使用了CeleryMixin和Tcelery。不适合我。

在此先感谢

回答

1

https://github.com/mher/tornado-celery允许从龙卷风

from tornado import gen, web 
import tcelery, tasks 

tcelery.setup_nonblocking_producer() 

class AsyncHandler(web.RequestHandler): 
    @asynchronous 
    def get(self): 
     tasks.echo.apply_async(args=['Hello world!'], callback=self.on_result) 

    def on_result(self, response): 
     self.write(str(response.result)) 
     self.finish() 
+0

叫芹菜任务不允许我与WebSocket的处理程序使用它。 – user3446151

+0

@ user3446151错误信息是什么? –