Can't run a thread in deployment enviroment

Question:
I’m running a flask server along a daily function in the workspace and all works fine. In Deployment it starts the flask server but don’t execute the daily function.

Repl link/Link to where the bug appears:
https://replit.com/@MessiasDidimo/omahav02#main.py

Screenshots, links, or other helpful context:
image

def run_server():
    app.run(host='0.0.0.0', port=8080)


if __name__ == '__main__':
    thread = Thread(target=run_at_specific_time, daemon=True)
    thread.start()  # Start the run_at_specific_time function in a separate thread
    run_server()  # Run Flask server in the main thread

You’re using autoscale I assume? Autoscale only runs when there’s an inbound request, the rest of the time it’s offline.

2 Likes

If you want to run a script at a specific time, consider using a “Scheduled” deployment.

2 Likes