简体   繁体   中英

apscheduler interval task is not running on aws

I would like to fire my job every few minutes. It is working on my local machine. However, on AWS Elastic Beanstalk the job never fires. I use python 3.4, apscheduler 3.1.0 and Flask 0.10.1.

For instance:

from apscheduler.schedulers.background import BackgroundScheduler

def my_job()
    print('Hello')


scheduler = BackgroundScheduler()
scheduler.add_job(my_job, 'interval', seconds=120, id='my_job')
scheduler.start()

Any ideas why it doesn't work on AWS?

you can use like this.

@application.before_first_request
def initialize():
    scheduler = BackgroundScheduler()
    scheduler.add_job(my_job, 'interval', seconds=120, id='my_job')
    scheduler.start()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM