my goal is to send live notifications to the user.
the message will arrive from a celery
worker.
and will be sent to the user using aiohttp
through sockjs
.
how can i run both on the same app ? or receive the messages on the aiohttp
instance where i have data of the authenticated users in memory ?
what is the best approach to achieve that ?
i have tried running them together using the aiohttp
on_startup
. but celery is blocking the main thread so its not possible.
async def run_celery(app):
.... run celery
app = web.Application(loop=asyncio.get_event_loop())
app.on_startup.append(run_celery)
sockjs.add_endpoint(app, msg_handler, name='messeging', prefix='/sockjs/')
thank you very much.
shay