docs
docs copied to clipboard
add doc to explain multithreading
Warning for interested
This PR likely requires major change before merged, if it ever will. The patterns mentioned should mostly work for current Streamlit, but the official team has the decide to how to introduce them.
📚 Context
Surprising many people are confused by multithreading in Streamlit, like in https://github.com/streamlit/docs/issues/87 / https://github.com/streamlit/streamlit/issues/1326 / https://github.com/streamlit/streamlit/issues/8490 .
This PR tries to explain the underneath Streamlit-specific things, and provide multithreading patterns to start with.
🧠 Description of Changes
- Add a page to explain Streamlit-created and user-created threads, and how to use them together.
Revised:
see the new file
Current:
(I didn't find document explaining threads and ScriptRunContext, except in the code)
💥 Impact
Size:
- [ ] Small
- [x] Not small
🌐 References
- https://github.com/streamlit/docs/issues/87
- https://github.com/streamlit/streamlit/issues/1326
- https://github.com/streamlit/streamlit/issues/8490
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
I'm happy to hear feedback about content or format :pray:
CI fails but I can't find the error message. The links like https://app.netlify.com/sites/streamlit-docs/deploys/66eaa4a1b1871d000843e854 only says "A fatal rendering error has occurred"
Hi @jokester. Thanks for contributing. The site won't build and the page won't be viewable without correctly updating site navigation. Check out the readme file for docs, specifically Add pages to the menu.
I'm going over items for the next release right now, so it might take me a few weeks to look at this more closely. Multithreading has been on my list for a while, so thanks for taking a stab at it. I'll circle back here when I get the next release fleshed out. 😄
@sfc-gh-dmatthews Thanks !! I managed to get preview build to work https://deploy-preview-1154--streamlit-docs.netlify.app/develop/concepts/architecture/threading
Sorry for the delay. I've been working on this this week. I think instead of the pseudo code to explain the threading structure, an illustration might be better. I have a much more detailed illustration I want to put into a contributing wiki-type document, but for this guide, I want to make sure it's as accessible to Python developers as possible (who might not ever touch a Tornado server to deal with WebSockets). I'm currently thinking of something like this to just schematically show script threads tied to script runs and that they have to communicate both to the front end and the server.
I should have the PR updated with a first pass by early next week. 😄