I have a flask app and it scraping web by using concurrent.futures and I want to run it in background every day in a certain time.
I have the following code
@app.before_first_request
def init_scheduler():
scheduler = BackgroundScheduler()
scheduler.add_job(my_job_function, trigger='cron', hour=6, minute=0)
scheduler.start()
atexit.register(lambda: scheduler.shutdown())
The code works in localhost as expected but it runs only one time when deployed. The job takes about 3 hours but I don't think it could be the problem. When the trigger is interval it works very well in localhost and deploy. I tested the code several times and i always faced this issue. Please excuse any typos.