Issue with Streamlit Sending Mixed Results in Concurrent User Sessions

Hello Streamlit Community,

I’m facing a challenge with my Streamlit application, particularly when handling concurrent user sessions. My application is designed to administer a personality test, and the results are sent to users via email. However, I’ve encountered an issue where, if multiple users (e.g., Person A and Person B) are using the app simultaneously, there’s a mix-up in the session management. As a result, Person A might receive Person B’s results, and vice versa.


  • Error Description: No specific error message, but incorrect session handling leading to mixed-up email results.

  • Attempts to Resolve: I’ve looked into session management in Streamlit but haven’t found a specific method to implement a queue system for handling multiple users. I’m unsure how to segregate individual user sessions effectively.

  • Streamlit Version: 1.26.0

  • Python Version: 3.9 (Anaconda)

  • Operating System: Tested on Windows 10, Windows 11 and MacOS Monterey

  • Deployment: The app is running locally during tests and also deployed at: (The app content is in Turkish).

  • GitHub Repo: Full source code is available here.

I’m looking for guidance or suggestions on how to ensure that each user session is handled independently, especially in a way that the email feature sends the correct results to each user. Any advice on implementing a queue or better session management in Streamlit would be greatly appreciated.

Session State is isolated for each user so there is nothing to do to segregate them. If you are getting some kind of mix, my first suspect would be caching or maybe a mishandled connection. (If a function is cached, then the saved output can be returned for other users.)

Can you be more specific about what mix you are observing?

I gether all personel information, i create a word document by their name and sent it to their e-mail adress.

Let think about 3 people, A B and C.

If a b and c press “complete” at the same time, the analysis creating for person A, but save as word document by person B’s name and sent to person C.

Also, person B’s anaylsis also sent to C. So who is the last complete test, gets all e-mails.

How are you saving and handling this document? Do you write anything to disk with non-unique filenames that might be read in another session? (I don’t quite have time to dig through your repo just now, so if you could point me to the right spot that would help.)

Okay, that is super cool!

I am not sure if you point that, but I also have a Google Drive API for save word docs to Google Drive. I just disabled it, and it works perfectly! I just tried with two users at the same time and will try four users.

I think the problem is about Google Drive API connection, also looked at console and saw this;

Traceback (most recent call last):

  File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/", line 541, in _run_script

    exec(code, module.__dict__)

  File "/mount/src/kyyk-renkler-kisilik/", line 24, in <module>


  File "/mount/src/kyyk-renkler-kisilik/", line 885, in kontrol_butonu

    send_mail.send_analysis(mail, [dosya_adi])

  File "/mount/src/kyyk-renkler-kisilik/", line 73, in send_analysis

    server.sendmail(FROM, TO, text)

  File "/usr/local/lib/python3.9/", line 901, in sendmail

    raise SMTPRecipientsRefused(senderrs)

smtplib.SMTPRecipientsRefused: {'': (555, b'5.5.2 Syntax error. Please visit\n5.5.2 and review RFC 5321\n5.5.2 specifications for more information. g12-20020a170902c38c00b001bbd1562e75sm1509755plg.55 - gsmtp')}

2023-10-20 17:07:26.002 Session with id 2af1d343-5075-4515-9902-49aeb28f4630 is already connected! Connecting to a new session.

It looks like an error about sending mail, but disabling Google Drive part is works fine right now!

1 Like

Module-level variables (like mail in are shared across sessions. So each time mail is assigned a value, it will be seen by all sessions. You probably want to store such values in session_state.

1 Like

Hi Goyo,

Thanks for your reply! I think I really need a session-based approach. I will try to reconstruct my app and also try it with Google Drive API. Thanks for your all suggestions!