TypeError: cannot pickle '_thread.RLock' object

Really frustrated with this - why isn’t this function working with cache_data?

@st.cache_data(ttl=CACHE_TTL)
def get_all_models(env):
    print(f"[{env.name}] Fetching Models")
    models_container = env.cosmosdb_client.get_container_client("models")
    models_query = "SELECT * FROM c"
    data = list(models_container.query_items(query=models_query, enable_cross_partition_query=True))
    return [Model(**model) for model in data]

I’m using a Pydantic model, and I’ve checked the return value without the cache_data decorator, and it’s all strings and booleans and numbers. I also tried without the Pydantic model, but I figured maybe some of the random CosmosDB variables were throwing things off (although those were also all strings).

edit Figured it out! I was passing a class as a parameter to that function, which apparently you can’t do?

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