python paramiko实现ssh远程登录
32位python的bug:os.system返回码一直为0

apscheduler提示maximum错误

妙音 posted @ 2015年12月15日 20:59 in python with tags tornado;apscheduler , 11809 阅读

起因

在tornado中用apscheduler实现计划任务,出现错误提示
 
2015-12-04 19:10:22,227 - apscheduler.scheduler - WARNING - Execution of job "TaskHandle.progress_job (trigger: date[2015-12-04 19:10:22 CST], next run at: 2015-12-04 19:10:22 CST)" skipped: maximum number of running instances reached (1)

分析

缺乏资料,所以根据提示,分析apscheduler源码
  • 记录异常位置
在源码目录下,搜索关键字maxinum,找到记录异常的位置
#apscheduler/schedulers/base.py
if run_times:
    try:
        executor.submit_job(job, run_times)
    except MaxInstancesReachedError:
        self._logger.warning(
            'Execution of job "%s" skipped: maximum number of running instances reached (%d)',
            job, job.max_instances)
    except:
        self._logger.exception('Error submitting job "%s" to executor "%s"', job, job.executor)
  • 异常抛出位置
 
继续看submit_job函数,找到异常抛出位置
#apscheduler/executors/base.py
def submit_job(self, job, run_times):
    """
    Submits job for execution.

    :param Job job: job to execute
    :param list[datetime] run_times: list of datetimes specifying when the job should have been run
    :raises MaxInstancesReachedError: if the maximum number of allowed instances for this job has been reached
    """

    assert self._lock is not None, 'This executor has not been started yet'
    with self._lock:
        if self._instances[job.id] >= job.max_instances:
            raise MaxInstancesReachedError(job)

        self._do_submit_job(job, run_times)
        self._instances[job.id] += 1
  • _instances变量作用
在submit_job(提交任务)时加1,在_run_job_success(任务运行成功)时减1。 当self._instances[job.id]大于job.max_instances抛出异常。
max_instances默认值为1,它表示id相同的任务实例数。

解决

通过设置max_instances参数
sched.add_job(child_job, max_instances=10, trigger=DateTrigger(), id="123")

重现脚本

import time
import tornado.ioloop
from apscheduler.triggers.date import DateTrigger
from apscheduler.schedulers.tornado import TornadoScheduler

sched = TornadoScheduler()

def child_job():
    print "start"
    time.sleep(60)
    print "end"

def main_job():
    sched.add_job(child_job, trigger=DateTrigger(), id="123")

sched.add_job(main_job, 'interval', seconds=5)

sched.start()
tornado.ioloop.IOLoop.instance().start()
  • 输出
job_id: 7279209ab6c2498698f2117bb97e18a1, instances: 0, max_instances: 1
job_id: 123, instances: 0, max_instances: 1
start
job_id: 7279209ab6c2498698f2117bb97e18a1, instances: 0, max_instances: 1
job_id: 123, instances: 1, max_instances: 1
WARNING:apscheduler.scheduler:Execution of job "child_job (trigger: date[2015-12-07 15:27:11 CST], next run at: 2015-12-07 15:27:11 CST)" skipped: maximum number of running instances reached (1)
job_id: 7279209ab6c2498698f2117bb97e18a1, instances: 0, max_instances: 1
 
Avatar_small
Robinjack 说:
2020年12月18日 18:36

I have prepared this updated practice exam with answers! 50 questions with answers. It will help you succeed in this certification exam abdelahad satour

Avatar_small
Robinjack 说:
2020年12月23日 17:33

BTW, and I hope we do not drag this too long, but care to remind us just what kind of weapons were being used on Kurds by Saddams army? To the tune of hundreds of thousands of dead Talk about re-written history babysitting Chico

Avatar_small
Robinjack 说:
2020年12月29日 17:58

A thoughtful insight and ideas I will use on my blog. You’ve obviously spent a lot of time on this. Thank you! buy lsd online

Avatar_small
샌즈카지노 说:
2021年1月05日 19:34

A thoughtful insight and ideas I will use on my blog. You’ve obviously spent a lot of time on this. Thank you! <a href="https://www.roroblog.com/sandscasino/">샌즈카지노</a>

Avatar_small
Ross Levinsohn Maven 说:
2021年1月08日 05:00

It’s not that I want to duplicate your website, but I really like the style. Could you tell me which design are you using? Or was it custom made?

Avatar_small
Robinjack 说:
2021年1月10日 23:15

Hello! I simply wish to provide a large thumbs up for any fantastic information you could have here about this post. I will be returning to your blog site to get more soon. Ross Levinsohn Maven Crunchbase

Avatar_small
Robinjack 说:
2021年1月10日 23:15

Oh my goodness! an incredible write-up dude. Many thanks Nevertheless My business is experiencing trouble with ur rss . Do not know why Cannot enroll in it. Perhaps there is anyone obtaining identical rss problem? Anyone who knows kindly respond. Thnkx Ross Levinsohn Maven profile

Avatar_small
Robinjack 说:
2021年1月10日 23:15

An impressive share, I merely with all this onto a colleague who was doing small analysis with this. And he in truth bought me breakfast simply because I found it for him.. smile. So ok, i’ll reword that: Thnx to the treat! But yeah Thnkx for spending plenty of time go over this, I believe strongly over it and really like reading much more about this topic. If at all possible, as you grow expertise, would you mind updating your blog with a lot more details? It is highly of great help for me. Large thumb up with this writing! Ross Levinsohn Maven

Avatar_small
Robinjack 说:
2021年1月10日 23:15

After study a few of the websites for your internet site now, and I genuinely as if your technique for blogging. I bookmarked it to my bookmark internet site list and will be checking back soon. Pls look at my website likewise and let me know what you think. Maven, Maven Sports Illustrated, the maven

Avatar_small
mespai 说:
2023年7月23日 12:48

<a title="situs slot demo" href="https://drsj.fis.ung.ac.id/public/journals/situs-slot-demo/" rel="Dofollow"><strong>situs slot demo</strong></a>,
<a title="situs demo slot" href="https://dev.sik.ntbprov.go.id/storage/slot-demo/" rel="Dofollow"><strong>situs demo slot</strong></a>,
<a title="situs slot demo" href="https://bkpsdm.temanggungkab.go.id/assets/demo/data/situs-slot-demo/" rel="Dofollow"><strong>situs slot demo</strong></a>,
<a title="slot pulsa 5000" href="https://icgh2016.ui.ac.id/slot-deposit-pulsa-5000/" rel="Dofollow"><strong>slot pulsa 5000</strong></a>,
<a title="slot mpo" href="https://gubug.dinus.ac.id/wp-content/uploads/2022/12/situs-slot-mpo/" rel="Dofollow"><strong>slot mpo</strong></a>,
<a title="situs slot pulsa 5000" href="https://gubug.dinus.ac.id/wp-content/themes/twentysixteen/slot-deposit-pulsa-5000/" rel="Dofollow"><strong>situs slot pulsa 5000</strong></a>,
<a title="agen slot 5000" href="https://if.teknokrat.ac.id/wp-content/plugins/elementor/includes/base/" rel="Dofollow"><strong>agen slot 5000</strong></a>,
<a title="slot mpo terbaru" href="https://fendi.lumajangkab.go.id/assets/admin/plugins/flots/data/situs-slot-mpo/" rel="Dofollow"><strong>slot mpo terbaru</strong></a>,
<a title="slot gacor" href="https://dkp3a.kaltimprov.go.id/slot-gacor/" rel="Dofollow"><strong>slot gacor</strong></a>,
<a title="slot server jepang" href="https://fendi.lumajangkab.go.id/assets/admin/plugins/flots/data/slot-jepang/" rel="Dofollow"><strong>slot server jepang</strong></a>,
<a title="slot pro jepang" href="https://fendi.lumajangkab.go.id/assets/admin/plugins/flots/data/slot-server-myanmar/" rel="Dofollow"><strong>slot pro jepang</strong></a>,
<a title="slot server vietnam" href="https://fendi.lumajangkab.go.id/assets/admin/plugins/flots/data/slot-server-vietnam/" rel="Dofollow"><strong>slot server vietnam</strong></a>,
<a title="situs slot pulsa 5000" href="https://dkp3a.kaltimprov.go.id/slot-pulsa-5000/" rel="Dofollow"><strong>situs slot gacor</strong></a>,
<a title="situs toto macau" href="https://dkp3a.kaltimprov.go.id/toto-macau/" rel="Dofollow"><strong>situs toto macau</strong></a>,
<a title="sayair hk" href="https://bkd.sulselprov.go.id/old/assets/sass/elements/syair-hk/" rel="Dofollow"><strong>sayair hk</strong></a>,
<a title="situs slot server kamboja" href="https://bkd.sulselprov.go.id/old/assets/sass/elements/situs-slot-kamboja/" rel="Dofollow"><strong>situs slot server kamboja</strong></a>,
<a title="slot deposit pulsa 5000" href="https://bkd.sulselprov.go.id/old/assets/sass/elements/slot-pulsa-5000/" rel="Dofollow"><strong>slot deposit pulsa 5000</strong></a>,
<a title="situs slot deposit pulsa 5000" href="https://disketpangan.kalbarprov.go.id/old/media/mailto/images/" rel="Dofollow"><strong>situs slot deposit pulsa 5000</strong></a>,
<a title="slot thaialand" href="https://disketpangan.kalbarprov.go.id/old/media/jui/img/" rel="Dofollow"><strong>slot thaialand</strong></a>,
<a title="erek erek 2d" href="https://mpi.inisnu.ac.id/wp-content/plugins/elementor/buku-mimpi-erek-erek/" rel="Dofollow"><strong>erek erek 2d</strong></a>,
<a title="situs slot mpo" href="https://mpi.inisnu.ac.id/wp-content/plugins/elementor/assets/slot-mpo/" rel="Dofollow"><strong>situs slot mpo</strong></a>,
<a title="akun pro thailand" href="https://mpi.inisnu.ac.id/wp-content/plugins/server/" rel="Dofollow"><strong>akun pro thailand</strong></a>,
<a title="situs server thailand" href="https://bkd.sulselprov.go.id/old/vendor/sweetalert/folder/slot-thailand/" rel="Dofollow"><strong>situs server thailand</strong></a>,
<a title="agen 5000" href="https://bkd.sulselprov.go.id/old/vendor/sweetalert/folder/situs-slot-pulsa/" rel="Dofollow"><strong>agen 5000</strong></a>,

Avatar_small
Imamia Quran Academy 说:
2023年7月27日 05:55

Hi everyone, I really love your story. You have very useful information; I am from Imamia Quran Academy. Shia Online Quran Academy is an institute for Quran Education. They have trained teaching staff along with renowned Islamic Scholars for a better understanding of the Quran.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter