V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
qq275327347
V2EX  ›  程序员

APScheduler 如何设置并发 job 数为 1?

  •  
  •   qq275327347 · 2021-06-28 21:17:44 +08:00 · 1070 次点击
    这是一个创建于 1004 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题。

    谷歌了一大圈都没找到,试了 'max_instances': 1 不管用,max_instances 是限制同一个 job 执行多个实例而非限制多个不同 job

    PS:我用来给游戏加 BUFF 的,所以并发按键没用,多了还存在被判定外挂的风险,手动捂脸……

    3 条回复    2021-06-29 04:32:00 +08:00
    magatama
        1
    magatama  
       2021-06-29 01:54:23 +08:00 via Android
    自己实现一个就行吧,你说的这个场景感觉不通用啊。。。所以官方未必会提供
    nikan999
        2
    nikan999  
       2021-06-29 04:30:03 +08:00
    https://apscheduler.readthedocs.io/en/stable/userguide.html
    你是指 配一下执行器的并发数吧 ,
    executors = {
    'default': ThreadPoolExecutor(20),
    'processpool': ProcessPoolExecutor(5)
    }
    根据文档 默认是 20 个线程
    nikan999
        3
    nikan999  
       2021-06-29 04:32:00 +08:00
    看错了,这是一个例子,可以配成 20 个,
    默认是 10 个,来自这句话
    This will get you a BackgroundScheduler with a MemoryJobStore named “default” and a ThreadPoolExecutor named “default” with a default maximum thread count of 10.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5878 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 02:19 · PVG 10:19 · LAX 19:19 · JFK 22:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.