mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 19:40:24 +00:00
19 lines
496 B
TypeScript
19 lines
496 B
TypeScript
import { logVerbose, shouldLogVerbose } from "../globals.js";
|
|
import { runTasksWithConcurrency } from "../utils/run-with-concurrency.js";
|
|
|
|
export async function runWithConcurrency<T>(
|
|
tasks: Array<() => Promise<T>>,
|
|
limit: number,
|
|
): Promise<T[]> {
|
|
const { results } = await runTasksWithConcurrency({
|
|
tasks,
|
|
limit,
|
|
onTaskError(err) {
|
|
if (shouldLogVerbose()) {
|
|
logVerbose(`Media understanding task failed: ${String(err)}`);
|
|
}
|
|
},
|
|
});
|
|
return results;
|
|
}
|