Is there any recommended solution for using streamlit session_states while running a part of your code with multiprocessing.Pool?
Of course, the problem is that by using multiprocessing, we run different processes (instead of the main streamlit run ā¦) and the new processes donāt inherit the session_states, resulting in KeyError. Iām curious to know whether thereās a workaround or itās a limitation that we have to deal with it (i.e. either using session_state or multiprocessing, and not both).
Sharing data between processes can be tricky. There are several ways of doing it documented in the multiprocessing module. The recommended solution would depend on the specifics of your use case.
Thanks for your reply @Goyo , but thatās not what I was looking for.
Indeed, sharing the states between the processes are tricky. But the question is if streamlit supports using of multiprocessing and session_state together?
You should be able to use both multiprocessing and session_state in a streamlit application. The workaround for ānew processes donāt inherit the session_statesā is sharing the data in some other way. I canāt be more specific without knowing more about your use case.