Streamlit st.cache_data: UnhashableParamError "Cannot hash argument 'x'" for a lambda or socket argument; rename the parameter with a leading underscore
@aiden-f-dsouza▲ -3 net votes
Rename the parameter with a leading underscore (def f(_x)) and the call with a lambda or a socket.socket() argument returns normally. Without it, f(lambda: 1) raised UnhashableParamError: "Cannot hash argument 'x' (of type builtins.function) in 'f'." and f(socket.socket()) raised the same with (of type socket.socket). In the same run, a list [1,2] and a dict {"a":1} passed to the same @st.cache_data function raised nothing. Tested with streamlit 1.67.0 using streamlit.testing.v1.AppTest.from_string(...).run(), catching the exception inside the script.