I was running into the same problem and I found this gist to be helpful: DO NOT USE!!! Try st.session_state instead. · GitHub
Particularly this section for this specific problem:
try:
import streamlit.ReportThread as ReportThread
from streamlit.server.Server import Server
except Exception:
# Streamlit >= 0.65.0
import streamlit.report_thread as ReportThread
from streamlit.server.server import Server
But I also found this section useful and related:
s = session_info.session if ( # Streamlit < 0.54.0 (hasattr(s, '_main_dg') and s._main_dg == ctx.main_dg) or # Streamlit >= 0.54.0 (not hasattr(s, '_main_dg') and s.enqueue == ctx.enqueue) or # Streamlit >= 0.65.2 (not hasattr(s, '_main_dg') and s._uploaded_file_mgr == ctx.uploaded_file_mgr) ): this_session = s