Forums

What is the best way to utilize long-running threads that launch other temp threads (previously run within a Flask app)?

To avoid wasted effort to adapt a threaded Flask web app (successfully runs locally), please help outline the PythonAnywhere capabilities for my purpose. Any direction here is much appreciated.

Since ‘threads are not supported in web apps’, does this include Python scripts run as tasks (where, for instance, one script would launch multiple continuous threads)?

Based on what appears possible with the sort of threading I am using (a couple 24/7 threads that sporadically launch a couple temporary threads), the following is my plan. Please let me know if it is on the right track:

Plan: Separate the threads from the Flask API. If possible (?), all threads would be run in one script, particularly in that (as stated) short threads are launched from within the long-running threads. This will continually update the database created on PythonAnywhere, and the Flask app will serve that data.

Threads are supported in other contexts, just not in web apps. Your plan to separate your threads out into a scheduled task sounds fine.