How to initiate tasks in celery to request a webcam in a tornado?

I am currently using a software stack like: Tornado (Websockethandler) + Celery (task manager) + RabbitMQ (amqp) + Redis as a backend.

However, I cannot integrate Tornado and celery for websocket requests. Can we have some pointers / examples for this?

Note. I used CeleryMixin and Tcelery. Not working well for me.

Thanks in advance

+4
source share
1 answer

https://github.com/mher/tornado-celery lets you name Celery tasks from Tornado

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()
+1
source

Source: https://habr.com/ru/post/1540501/


All Articles