Did you manage to solve it? I have a similar need and trying to understand if Dash runs the server inside an AsyncIO event loop or if I can simply start one for the background tasks, separate from Dash.
If you dont want to add a queue and background worker to your app, you can use GitHub - chgiesse/flash: Async port of Dash, it is running Quart as Server instead of Flask, which enables Dash with native async capabilities.
Hi @Datenschubse! Thank you for the intro and the links, I’m looking at that GitHub now. I was playing around with asyncio and Dash yesterday and it looks like it runs the render threads in different event loops. Any idea where I can learn more about that?
Thanks!
Yes Dash is not compatible with asyncio. For an async backend you would deploy with uvicorn (asgi) instead of gunicorn (wsgi) which handles the event loop. If you want to learn more about async in general - have a look at the official asyncio documentation and start with focusing on basic coroutines, asyncio gather and tasks.
Hi @maxim.yudayev, I have to revise my statement here. They support async functions since Flask 2.0 with spawning sub threads with their own asyncio event loops. I found a really good article about this Async in Flask 2.0 | TestDriven.io
That said, while you can run async functions the request itself gets processed like a normal wsgi server.
I hope this helps and sorry for the wrong statement !