main.py 885 B

12345678910111213141516171819202122232425
  1. from app import create_app
  2. #from apscheduler.schedulers.background import BackgroundScheduler as BS
  3. #from apscheduler.triggers.cron import CronTrigger
  4. #from app.dispatch import check_auction_end
  5. app = create_app()
  6. if __name__ == '__main__':
  7. '''
  8. with app.app_context():
  9. # Background Scheduler for Background tasks
  10. #app.app_context().push() # need to wrap this in app context
  11. sched = BS(daemon=True)
  12. if not sched.running:
  13. print(f'DEBUG: STARTING SCHEDULER')
  14. # pass the function of check_auction_end, don't call
  15. #sched.add_job(check_auction_end, CronTrigger.from_crontab('0 0 * * *'))
  16. #sched.add_job(check_auction_end, CronTrigger.from_crontab('*/2 * * * *'))
  17. sched.add_job(check_auction_end, trigger="interval", seconds=60)
  18. sched.start()
  19. '''
  20. app.run(debug=True)