Amir H
Amir H

Reputation: 125

APScheduler code from Python 3 to Python 2

The following code was written in 3.5 to gather data in 1 hour intervals from an online source.

My code consist of two functions as below:

  1. a "Main" function which is executed every 1 hour using "cron" scheduling type.
  2. a "Check" function which is executed every 2 minutes using "interval" scheduling type.
def Main():
    # perform a task
def Check():
    # check if the main task is being done

scheduler = BackgroundScheduler()
scheduler.add_job(Main, 'cron', month='*', day='*',day_of_week='*', hour='0-24', minute='0')
scheduler.add_job(check(Check, 'interval', minutes=2)
scheduler.start()

In Python 3, the code performs as intended: the "Main" function executes at the beginning of every hour and the "Check" function runs every 2 minutes.

I have attampted to reuse the same code in Python 2.7 on Mac with APScheduler of version 3.3.0; however, in Python 2.7 when run the code, the "Main" function starts immediately and not at the beginning of the hour.

What could be the cause of this issue?

Upvotes: 0

Views: 699

Answers (0)

Related Questions