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

2021-06-28 21:17:44 +08:00
 qq275327347

如题。

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

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

1089 次点击
所在节点    程序员
3 条回复
magatama
2021-06-29 01:54:23 +08:00
自己实现一个就行吧,你说的这个场景感觉不通用啊。。。所以官方未必会提供
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
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.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/786326

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX