Closed incadroid closed 1 year ago
Hey guys, incase anyone comes accross a similar issue. I was able to create a "schedule_intervals" function to run that code in a different for loop for some of the uncommon intervals. Here is an example that solved my 80 minute dilemma:
def schedule_intervals(): now = datetime.now() next_midnight = (now + timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
schedule.every().day.at("00:00").do(run_bot_1440)
for i in range(0, 1440, 30):
schedule.every().day.at((next_midnight + timedelta(minutes=i)).strftime("%H:%M")).do(run_bot_30)
for i in range(0, 1440, 60):
schedule.every().day.at((next_midnight + timedelta(minutes=i)).strftime("%H:%M")).do(run_bot_60)
for i in range(0, 1440, 80):
schedule.every().day.at((next_midnight + timedelta(minutes=i)).strftime("%H:%M")).do(run_bot_80)
schedule_intervals()
while True: schedule.run_pending() time.sleep(1)
Hopefully it helps someone else along the way ! Cheers (other intervals can be added with their own for loops and proper steps)
Apologies as this really isn't an 'issue' or technical bug with the package. However Im just looking for some help.
I have been using schedule to run jobs at specific intervals using the for loop method below in these examples:
for hour_15, minute_15 in product(range(0, 24), range(0, 60, step_15)): time_15 = "{hour:02d}:{minute:02d}".format(hour=hour_15, minute=minute_15) schedule.every().day.at(time_15).do(run_job_15)
for hour_180, minute_180 in product(range(0, 24, step_180), range(0, 60, step_60)): time_180 = "{hour:02d}:{minute:02d}".format(hour=hour_180, minute=minute_180) schedule.every().day.at(time_180).do(run_job_180)
The first loop is for 15 minute task, the 2nd is for 3 hourly task. However, I cannot figure out the way to get schedule to work with intervals of 80 or 90 minutes.
Any help would be greatly appreciated! And thanks for the great work on the package. Cheers.