Be able to close cached resources (@st.cache_resource) #8674
Labels
feature:cache
Related to st.cache_data and st.cache_resource
type:enhancement
Requests for feature enhancements or new features
Checklist
Summary
@st.cache_resource
is recommended to use for non-hashable resources like database connections. However, such resources might require closing.Why?
@st.cache_resource
is recommended to use for non-hashable resources like database connection. From the doc:However, these resources could require closing (closing the database connection, stopping a
SparkSession
).In the current implementation I'm not able to close the connection, requiring the streamlit instance to be restarted. For database connections this will result in dangling connections.
How?
Ideally I'd be able to close the resource in the same function similar to PyTest yields usage:
Alternatively, perhaps a close callback:
Additional Context
No response
The text was updated successfully, but these errors were encountered: