Hello all from the documentation of streamlit I understand that using the @st.cache will just execute the function once. Because I wouldn’t want to keep connect to database every time the script is reruns. From my code below I have this function that does the initialization of the database and other function would make use of this object to get data from the database. However, when script is started, after running for quite sometime there will be this internal hash error. It says that maximum recursion depth exceed in comparison. Streamlit encountered an object of type builtins.method which it does not know how to hash.
Is this the correct way to cache an object for use in other function?
from database import db
import streamlit as st
@st.cache(hash_funcs={db: lambda _: None})
def init_db():
database = db()
database.init()
return database
database = init_db()
def get_data():
st.text(database.get_data())