Concurrent Users Seeing Each Other's Data

I have a Streamlit App which I deployed to https://multidest.onrender.com/ on Render. However, it appears that when multiple users send a query at once that it cross contaminates, sending all results to everyone. Is there a way to silo off requests, and would Sessions be a valid solution here?
My code is hosted here, in case its helpful for answering the question: Github Repo

Thanks!

To expedite things, please could you identify which specific line/request your are seeing duplicated? Ideally, could you make a simplified version to show a minimal code sample to reproduce the issue so we aren’t digging through multiple files to find and test what you are referring to?

1 Like

It appears that the entire program is being duplicated, as from line 122 in stream.py, where the program begins with deleting any existing CSV where results are pulled from, results are combined, with all results being read into the same CSV in lines 208, 217, and 226. This causes the data being displayed in lines 252 and downwards to be mixed with other user’s input. Would creating separate sessions enable the CSV creation to be “siloed” to each concurrent user?

Let me know if there’s anything more particular that would help, and I’ll try to make a minimal version when I get a chance. Thanks!

The root of the problem is that you are trying to use a single .csv file as a sort of a database? This will never work, but looking at your app I do not see why you would need to save this data anywhere. You can just get it, display it and be done with it.

If you are fine with the data getting refreshed on every interaction, simply assign the request responses and dataframes and what have you to variables in your script and print them out. If you want to store some data for the current session, use st.session_state.

If you want to offer the user a downloadable csv, either generate a random filename for that particular user yourself or use the tempfile module (the latter would be generally better).

2 Likes