schedule
schedule copied to clipboard
the time of job needed will be count for every ?
def job():
global count
logger.info("I'm doing a periodic job!" + str(count))
count = count + 1
time.sleep(30)
# 每隔 2 分钟执行一次任务
job()
schedule.every(2).minutes.do(job)
while True:
# logger.info("waiting for")
schedule.run_pending()
time.sleep(1)
the log is
2024-03-18 12:03:44,170 - INFO - I'm doing a periodic job!0
2024-03-18 12:06:14,534 - DEBUG - Running job Job(interval=2, unit=minutes, do=job, args=(), kwargs={})
2024-03-18 12:06:14,535 - INFO - I'm doing a periodic job!1
2024-03-18 12:08:44,888 - DEBUG - Running job Job(interval=2, unit=minutes, do=job, args=(), kwargs={})
2024-03-18 12:08:44,889 - INFO - I'm doing a periodic job!2
2024-03-18 12:11:15,267 - DEBUG - Running job Job(interval=2, unit=minutes, do=job, args=(), kwargs={})
2024-03-18 12:11:15,267 - INFO - I'm doing a periodic job!3
2024-03-18 12:13:45,660 - DEBUG - Running job Job(interval=2, unit=minutes, do=job, args=(), kwargs={})
2024-03-18 12:13:45,660 - INFO - I'm doing a periodic job!4
the code want job run every 2 minutes ,but it run every 2:30 minute , include the time the job costed.
Is this as expected? or Bug ?