Got that asyncio feeling? How to run async code in Streamlit

Bet you’ve tried to run async code in Streamlit only to encounter the dreaded exception message: "RuntimeError: This event loop is already running” ! What does that even mean?

This is a topic that so many in this forum struggle with because of Streamlit’s synchronous programming model. Powerful though that is, because it lowers the barrier to entry and maximizes productivity, it can also lead to a sinking feeling when you need to do async. In this article I show you exactly how to tame the monster and fall in love with asyncio in Streamlit.

3 Likes

I learned this lesson when first using chainlit.
Thanks for sharing

1 Like