MCPcopy
hub / github.com/promptfoo/promptfoo / execute

Method execute

src/python/workerPool.ts:66–84  ·  view source on GitHub ↗
(functionName: string, args: unknown[])

Source from the content-addressed store, hash-verified

64
65 // biome-ignore lint/suspicious/noExplicitAny: FIXME
66 async execute(functionName: string, args: unknown[]): Promise<any> {
67 if (!this.isInitialized) {
68 throw new Error('Worker pool not initialized');
69 }
70
71 // Try to get available worker
72 const worker = this.getAvailableWorker();
73
74 if (worker) {
75 // Worker available, execute immediately and trigger queue processing when done
76 return worker.call(functionName, args).finally(() => this.processQueue());
77 } else {
78 // All workers busy, queue the request
79 return new Promise<unknown>((resolve, reject) => {
80 this.queue.push({ functionName, args, resolve, reject });
81 logger.debug(`Request queued (queue size: ${this.queue.length})`);
82 });
83 }
84 }
85
86 private getAvailableWorker(): PythonWorker | null {
87 for (const worker of this.workers) {

Callers 15

database.test.tsFile · 0.45
workerPool.test.tsFile · 0.45
agents.test.tsFile · 0.45
isolation.test.tsFile · 0.45
import.test.tsFile · 0.45
callActiveProviderFunction · 0.45
executePythonScriptMethod · 0.45
configureDatabaseFunction · 0.45
closeDbFunction · 0.45
resetTestDatabaseClientFunction · 0.45

Calls 4

getAvailableWorkerMethod · 0.95
processQueueMethod · 0.95
callMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected