Streamlit and asynchronous functions

The awaitable task is not run concurrently as you might be expecting. It’s just being scheduled to run and will run like any sequential (blocking) function call. Try using loop.run_in_executor() (or concurrent.futures.ThreadPoolExecutor()) to run it in a thread. See this doc.

I haven’t tried myself, but you could wrap streamlit.bootstrap.run() in an awaitable task and run both tasks concurrently. See this doc.

If you get it working, please post your solution.

Cheers,
Arvindra

1 Like