mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
重构任务并发执行逻辑
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import pLimit from "p-limit";
|
||||
import os from 'os';
|
||||
|
||||
const cronLimit = pLimit(os.cpus.length);
|
||||
|
||||
export function runCronWithLimit<T>(fn: () => Promise<T>): Promise<T> {
|
||||
return cronLimit(() => {
|
||||
return fn();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user