When using concurrent.futures
with st.cache_data
together, the console shows the following warning but doesn’t affect the result. If using a single thread, it works without any warning.
WARNING streamlit.runtime.caching.cache_data_api: No runtime found, using MemoryCacheStorageManager
Here is a simple code example:
import concurrent.futures
import streamlit as st
from numpy import random
def run():
int_list = get_int_list(10)
st.write(int_list)
@st.cache_data
def get_int_list(length):
int_list = []
# single thread
# for i in range(length):
# int_list.append(get_randint())
# concurrent.futures
with concurrent.futures.ProcessPoolExecutor() as executor:
futures = [executor.submit(get_randint) for i in range(length)]
for future in concurrent.futures.as_completed(futures):
int_list.append(future.result())
return int_list
def get_randint():
return random.randint(1, 100)
if __name__ == '__main__':
run()
It doesn’t seem to matter, but is there any way to avoid the problem?