Page refreshes and raises script_runner.StopException

I’m not sure how to ask this question properly, because I can’t come up with a minimal example that others could reproduce. I guess I’m looking for ideas on what could be causing the problem.

I have a streamlit application that will sometimes “fade” (the page looks like it is refreshing), and the next time the code writes to the page (e.g. with streamlit.write() or updating the value of a streamlit.empty()) the page will refresh and raises a script_runner.StopException.

I’m thinking it has to do with the code running for too long. The code repeatedly calls an optimization (integer programming) solver on a remote machine, and each call to the solver can take several minutes to return. Sometimes the error happens on the first call to the solver within a run of the code, sometimes after many - with everything else being equal, it’s not consistent.

Any ideas what is causing this? I can’t replicate the error without calling the remote optimization solver, so I can’t share an example.

I’m running Windows 10, python 3.7.7, streamlit 0.66.0, and had same error with 0.62.0.

Hey @Ldlt012, welcome to the community.

My first thought would also be timeout issues or connection cut by something, but I don’t know who interrupts it, is it Streamlit, the remote machine or even a firewall in between…

  • How do you contact the remote machine? Is it a REST endpoint for example? Does it also happen if you run the algo without Streamlit, that is in python console or jupyter notebook ?
  • Which library do you use to connect to the machine and how is it configured ?
  • Is the remote machine on the same network? Is there a firewall in between ?
  • Could you share the part where you call the remote optimization solver and return the results of it? I understand we won’t be able to reproduce the code but we may be able to “imitate” it’s behavior by mocking said remote optimization solver to return a value after x minutes (and that could even be in a Docker container). Maybe the way you call it makes Streamlit timeout at some point (I don’t believe that but since I’m brainstorming by writing, we never know)

Those are the things I would try out of my head :wink: good luck!