@st.cache_data Behavior issue

Hello,
I would like to know if there is a problem with “@st.cache_data”, these 2 last days, I’ve noticed that functions with “@st.cache_data” decorator are no longer cached correctly and rerun as if the cache was at 0(ttl=0s).

For other information :

  • I have noticed this behavior on the apps deployed on the streamlit community cloud, and when i run the app locally, i got this eror message :
streamlit\util.py:227: RuntimeWarning:

coroutine 'expire_cache' was never awaited
  • I haven’t changed my code for a while, and here is how i decoracte the functions :
@st.cache_data
def function(parameter1, parameter2):
    ...code

Thank you for your help !

1 Like

Hi @Snow_Yoo,

Thanks for bringing this up.

Can you share some of the apps on Community Cloud that you’re seeing the issues with caching?

1 Like

hello thank you for your reply, i cannot share this app because it’s a private one for teamwork, but here is a eror message i have on the Manage app logs :

/home/adminuser/venv/lib/python3.9/site-packages/streamlit/util.py:227: RuntimeWarning: coroutine 'expire_cache' was never awaited

  pass

RuntimeWarning: Enable tracemalloc to get the object allocation traceback

This app is continuously loading and reloading the main function. I have only a side bar with a spinner that keeps running without stopping, displaying messages like: 'Running get_function... '"

1 Like

Hi, Even I am facing the same issue. Any solution?

1 Like

I am getting the same error

1 Like

I am getting the same error with @st.cache_resource. Updating to 1.32.0 breaks my application because of this.

1 Like

for the time being go and use cachetools.func.ttl_cache as workaround.
functionality for user should be alsmost the same, except that progress animation will be not showing.

and yes, after updating to 1.32 iam facing same issue.

1 Like

Same issue here, after updating to 1.32:

streamlit/util.py:227: RuntimeWarning:

coroutine 'expire_cache' was never awaited
1 Like

Im also getting this:

streamlit/util.py:227: RuntimeWarning: coroutine ‘expire_cache’ was never awaited
pass
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

But im seeing this warning after integrating asyncio and im using @st.cache_data decorator. it might be due to an incompatibility or incorrect usage of asynchronous functions with Streamlit’s cache.

But it doesn’t directly affect the functionality of my app. Just slowing initial loading.

1 Like

Same problem here. Didn’t occur before I updated from 1.31.1 to 1.32.0. Doesn’t happen now after I reverted back to 1.31.1. I don’t need anything from 1.32.0 so I’ll just stick to 1.31.1 for now.

1 Like

We have an issue with the 1.32.0 version which causes the mentioned RuntimeWarning and our CPU utilization to max out :frowning: The 1.32.1 patch will likely fix that, but it needs a bit further evaluation.

2 Likes

Hi, I have the same problem with @st.cache_data in 1.32.

1 Like

That was fast: Revert "Expire session storage cache on an async timer (#8083)" (#8281) · streamlit/streamlit@b6f71f9 · GitHub

Thanks for pushing out 1.32.1 so quickly.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.