Skip to content

Commit

Permalink
chore: reduce to 7 concurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
ctjlewis committed Apr 15, 2024
1 parent 75dfbe2 commit 65b47e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/backoff.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ export async function backoff(action, maxRetries = 6, initialDelay = 15) {
let retries = 0;
let delay = initialDelay;

while (retries < maxRetries) {
while (true) {
try {
const results = await action();
return results;
} catch (e) {
if (retries === maxRetries) {
throw new Error('Max retries exceeded.');
}

retries++;
console.error(e.message);
console.error(`Error. Retrying in ${delay}s. [Attempt ${retries}/${maxRetries}]`);

await new Promise(resolve => setTimeout(resolve, 1000 * delay));
delay *= 2;
if (retries <= maxRetries) {
console.error(`Error. Retrying in ${delay}s. [Attempt ${retries}/${maxRetries}]`);
await new Promise(resolve => setTimeout(resolve, 1000 * delay));
delay *= 2;
} else {
throw new Error('Max retries exceeded.');
}
}
}
}
2 changes: 1 addition & 1 deletion src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ async function runFullChallenge(systemPrompt, runs = 50, batchSize = 1) {
console.log();
}

await runFullChallenge(prompt, 500, 10);
await runFullChallenge(prompt, 500, 7);

0 comments on commit 65b47e8

Please sign in to comment.