APScheduler和Heroku:跳过作业的执行:达到的最大运行实例数

时间:2017-05-06 16:01:04

标签: python heroku apscheduler

3年前在这里发布了类似的问题:

WARNING:apscheduler.scheduler:Execution of job skipped: maximum number of running instances reached (1)

但这个问题从未得到完全回答。

我有每3个小时执行一次的进程。我关闭了我的命令以更新我的数据库,但不知何故他们没有关闭。所以在几周内我得到了错误"跳过了作业的执行:达到最大运行实例数(1)。但无论如何,有没有办法终止我的命令,以便他们腾出来并且不会累积?

原帖提示了一个名为proc.terminate的命令。这是什么图书馆?我如何在python中实现它?

这是值得的,这是我在APScheduler的日程安排

@scheduler.scheduled_job('cron', hour='0,3,6,9,12,15,18')
def clock_scheduled_commands():
    print('Updating Tables')
    updatePrices.main()
    print('Updating Margins')
    calculateMargins.main()
    #print('Pushing to Perm')
    #PushToPerm.main()
    print(time.strftime("%A, %d. %B %Y %I:%M:%S %p"))

请注意,updatePrices.main()和calculateMargins.main()都返回0表示它们已完成。它们也都在最后关闭光标(据我所知)。

编辑:这是我要求的Heroku的Procfile:

web: gunicorn controller:app
clock: python scripts/clock.py

1 个答案:

答案 0 :(得分:0)

在updatePrices和calculateMargins中,我在每个事务中打开和关闭游标。我认为这会引起问题。

相关问题