I was trying to find more info how Streamlit executes scripts, but could not find it in the documentation. So, for example, if I run time.sleep(5) in my app - where is script execution concurrency coming from? It does not seem to be using worker processes or asyncio, so is it using threads under the hood? Can somebody point me to a doc page which explains this in more detail? Thanks
My understanding is that the application runs in a single process using a thread per session. I learned that in a forum post by a developer that I cannot find right now. I am not aware of any documentation about this.
I’ve seen the post goyo mentions, it is here.
But from my experience it is a single thread per page (I use multi-page app), and this thread is seemingly shared across users. I wish there was some clarity around this.
Yes, it was that.
I wonder what makes you think that. It would be in direct contradiction with what tim said and it should have effects that I am not seeing.
So I have one page in the app that is single-threaded and quite computationally/IO intensive.
For experiment, I’ve opened this page and launched job, then opened the same in another browser.
Page in second browser started loading only after job was completed in the first browser. All other pages in multi-page app were loading in parallel normally. I don’t think there is any kind of lock on the page. Also note this happened on a server.
I’ve made a simple test on mac with time.sleep() and behavior there is different - clearly there are separate threads for different sessions.