mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 06:46:09 +08:00
10 lines
218 B
TypeScript
10 lines
218 B
TypeScript
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();
|
|
});
|
|
} |