Hey @JAGD,
I wanted to share some notes by @tim on multithreading from this related GitHub Issue:
None of Streamlitâs APIs are safe to call from any thread other than your scriptâs main thread; code that does so has ventured into the realm of undefined behavior, and we strongly recommend against it
If you need to run a separate thread that invokes Streamlit APIs, youâll need to do something like pushing requests to a shared queue thatâs processed by your script thread.
(This isnât something thatâs particularly easy to do with Streamlit, unfortunately. But we do have some - still vague - plans to make more complex use cases, like this one, less tricky!)
Based on the above, it seems like what youâre seeing is unfortunately expected behavior. Agreed that we should document this more publicly for reference.