MCPcopy Create free account
hub / github.com/cortexkit/magic-context / worker

Function worker

packages/plugin/scripts/longmemeval/runner.ts:920–944  ·  view source on GitHub ↗
(workerIndex: number)

Source from the content-addressed store, hash-verified

918 let fatalError: Error | null = null;
919
920 async function worker(workerIndex: number): Promise<void> {
921 while (nextIndex < workItems.length && fatalError === null) {
922 const current = workItems[nextIndex];
923 nextIndex += 1;
924 if (!current) break;
925 logLine(`Worker ${workerIndex} processing ${current.question.question_id}`);
926 try {
927 await processQuestion({
928 client,
929 config,
930 question: current.question,
931 datasetIndex: current.datasetIndex,
932 state,
933 resultsMap,
934 });
935 } catch (error) {
936 fatalError = asError(error);
937 await appendLog(
938 config.paths.logFile,
939 `Worker ${workerIndex} stopping due to failure on ${current.question.question_id}: ${fatalError.message}`,
940 );
941 break;
942 }
943 }
944 }
945
946 await Promise.all(Array.from({ length: workerCount }, (_value, index) => worker(index + 1)));
947 if (fatalError) {

Callers 1

runWithParallelismFunction · 0.85

Calls 4

logLineFunction · 0.85
processQuestionFunction · 0.85
appendLogFunction · 0.85
asErrorFunction · 0.70

Tested by

no test coverage detected