About app: I am already running a streamlit app on streamlit clould which highly uses session-state as to allow flow of information between pages. It is meant for multiple users at same time and to prevent cross talks have not used any data caching.
Doubt: I am also running a subprocess python script which will need information/results to be fetched from streamlit data processing pages script either in form of csv or yaml or json or other files to transfer information to this subprocess script.
So if multiple user’s files are getting saved in csv format at the same time then is it getting saved only in their own session ?
If in session then csv file fetched by them running in that session will also fetch the session based csv file only … is this correct and expected or is it Global and not the session based ?
I want to keep the transfer of files/information within the session from streamlit generated data analytics to subrocess running python script in that session.
I am New to subprocess and session sort of development so not sure how it will be handled within streamlit.
Session State is tied to a particular session, yes. If you save something in Session State, it’s only available to that one user in that one session where it was saved. If the same user opens another tab, they start a new session and don’t have access to the data in Session State from their original tab.
If you write to a file on disk, it will be available to all sessions.
If you cache data, it will be available to all sessions.
I am planning to write the file like csv but I want to link that file to that particular session only so that one user doesn’t overwrite another user’s file with same name and cause cross talk.
Workaround I can think of is to get some session id info (unique ids) and by using that as part of name I can save/write the file on disk so that when Quarto qmd file runs in same streamlit session then it can read the file saved with same session name.
Is it possible to get session info or session id ?
import uuid
import streamlit as st
def get_session_id():
if "_session_id_" not in st.session_state:
st.session_state["_session_id_"] = uuid.uuid4()
return st.session_state["_session_id_"]
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.