Background process on streamlit app

  1. Are you running your app locally or is it deployed: application used for the moment locally before deployment
  2. no deployment link
  3. If your app is deployed: no link
  4. Share the link to your app’s public GitHub repository : no repository
  5. Share the full text of the error message : no error message
  6. Share the Streamlit and Python versions : python 3.10 and streamlit 1.36.0

Hello,
I search to define a streamlit website that use background processes that can be launched with thread to gain in performances.

I see post giving some solutions but it’s not good in my case.

Concurrency with streamlit - #4 by asehmi give solution with add_script_run_ctx to thread expensive CPU algorithms.

But I remark if I create a thread from the main.py file that launch a streamlit application => the thread is restarted each time a user is moving on pages of the site app. (for example if main.py is the home page launcher to load other pages => main.py is already executed. I detail my site starter is “streamlit run main.py” launching the frontend app)

In this case, if I go to home page or any page referred from home page => the main.py is executed at each page load and the thread process restarted => I cannot define a threaded process that share data for several pages.

So how to define a process threaded that can be shared for several pages (so several *.py scripts) and in this way share data between several pages ?

The use of add_script_run_ctx seems to be not ok because for each page loading, the context is changing and the main.py re-executed.

Thank you to help me to define a way to launch a background process (so a python file process that could be launched once, and than referred for any new user that could go to the streamlit site without restarting all the time)

Regards

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.