python - Celery + RabbitMQ Results Backend + WebSockets? -


i have flask web app , there tasks long running (> 1 minute). offload these flask (blocking web server, etc) , move them external tasks. got celery setup , able run these tasks flask. good.

to notify users when task done , return results, wanted use web sockets. gets hard.

i have gevent websocket server running client connects to. when launch celery task pass in session id of client when results know belong to.

now need websocket server know when these tasks done, @ results, , send them appropriate connection.

how? lost. can listen celery events celery.events.eventlistener.capture, blocks websocket server can't have multiple connections!

how can listen celery events without blocking?

one idea make request on web socket , launch celery task websocket server. solve notification issue (just used celery events), i'm still curious original question request made standard flask server.

you need flask app not block on capture call. 1 solution run flask gevent or eventlet process handle request asynchronously , blocking calls not block process.

there tons of examples this, name one: https://gist.github.com/lrvick/1185629


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -