Hi everyone! When I run my app myself it works fine. However, I decided to test how the app behaves when 2 users use it simultaneously. I started running the app in 2 tabs in the browser simultaneously. One of the sessions receive an error about “pymol.CmdException”. However exactly the same app worked just a minute ago run completely fine when run by only one user. Do you know, why two users interact with each other? My app is here: https://spikescape.streamlitapp.com/
I think that sessions for some unknown reasons interact with each other. I am quite new to Streamlit, so I might be wrong. I would really appreciate your help.
Thank you very much!
pymol, which I assume you’re using in the back end, isn’t thread safe or has a contention accessing one of its resources, such as a file. You’ll therefore have to arrange for your calls to
pmol to be gated by user session, using a mutex. Perhaps Python’s lock objects can help.
thank you very much @asehmi ! indeed, I noticed that pymol loads files from different sessions in the same kind of shared memory or something like this. The bottom line is that the user from one session can actually access loaded data by the other user in the other session. this is the problem. I will read about mutex, never did it before.
@asehmi Do you by any chance know, why the pymol does not create separate sessions for each user?
I’m not a pymol user (nor a molecular biologist / chemist), but from what I can tell PyMol python is a wrapper on a command line script, so very likely there is process or file contention. You should look into launching pymol from a queued job scheduler or launch separate processes per user session. For each user session you’ll need to create separate file store roots to avoid write collisions. Plus, depending on the workload, you will need to limit the number of concurrent processes launched. More advanced, you could use lambdas (Azure Functions, AWS Lambda) to do the PyMol work. It gets complicated if you want to handle errors and do clean up.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.