【问题标题】:Python scheduler on top of a scheduler调度程序之上的 Python 调度程序
【发布时间】:2020-08-31 09:53:42
【问题描述】:

我有一个安排在每周一上午 9:00 举行的活动。

在该计划运行之后,我需要每小时重复一次该功能。

这是我的代码:

import schedule
import time

def main_job():
    print('Hello World')

def schech():
    schedule.every().minute.do(main_job)

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


schedule.every().day.at("17:46").do(schech)

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

我得到的错误:

RecursionError: 超出最大递归深度

【问题讨论】:

  • RecursionError: 超出最大递归深度

标签: python macos schedule


【解决方案1】:

删除 schech() 函数中的 while 循环。

import schedule
import time

def main_job():
    print('Hello World')

def schech():
    main_job()
    schedule.every(60).minutes.do(main_job)

schedule.every().day.at("9:00").do(schech)

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

【讨论】:

    猜你喜欢
    • 2018-05-22
    • 2011-01-19
    • 2023-04-04
    • 2019-04-13
    • 2017-05-07
    • 1970-01-01
    • 2012-05-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多