如何使用schedule包精确地安排python作业每小时运行一次

2024-04-16 22:40:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用schedule python包,希望每小时在:00点运行一个作业

这可能吗

这是我现在掌握的代码:

def schedule_jobs(self, loop):
    logging.info('Starting scheduler...')

    schedule.every(1).hours.do(self._pldown_runner.run_pldown_job, loop)

    while True:
        schedule.run_pending()
        time.sleep(1)

问题是,从实际执行作业的那一分钟开始,它每小时运行一次作业


Tags: run代码selfinfolooploggingdef作业