I’m reading a few files for parameters and load a language model into my Python program and assign them to variables in a file outside the streamlit script in order to execute.
config.py
INSTANCE = None
def get_config():
Read file and assign content to INSTANCE
if INSTANCE is None.
Then return INSTANCE
app.py
import streamlit as sr
get_config()
When I do streamlit run app.py and only start with 1 tab/session it reads the file and
consecutive sessions don’t need to read the file anymore.
But when I start multiple sessions shortly after the file will be read multiple times.
I couldn’t find too much discussion about this problem but 1 obvious way is to load in files before session connects. If that’s not possible read in the files thread-safe but for this I need a Lock from the main thread afaik(?)
Hope my problem comes through and is solvable