reset counter, for loop, sleep 1s

Signed-off-by: blakeromano-il <blake.romano@imaginelearning.com>
This commit is contained in:
blakeromano-il
2022-05-18 09:09:22 -04:00
parent fde10d24f6
commit a9f6b49f1c
2 changed files with 6 additions and 4 deletions
@@ -40,10 +40,9 @@ export class LocalTaskWorker {
this.logger.info(
`Task worker starting: ${this.taskId}, ${JSON.stringify(settings)}`,
);
const success = false;
let attemptNum = 1;
(async () => {
while (!success) {
for (;;) {
try {
if (settings.initialDelayDuration) {
await this.sleep(
@@ -63,12 +62,14 @@ export class LocalTaskWorker {
);
}
this.logger.info(`Task worker finished: ${this.taskId}`);
attemptNum = 0;
break;
} catch (e) {
attemptNum += 1;
this.logger.warn(
`Task worker failed unexpectedly, attempt number ${attemptNum}, ${e}`,
);
await sleep(Duration.fromISO('P1S'));
}
}
})();
@@ -51,10 +51,9 @@ export class TaskWorker {
this.logger.info(
`Task worker starting: ${this.taskId}, ${JSON.stringify(settings)}`,
);
const success = false;
let attemptNum = 1;
(async () => {
while (!success) {
for (;;) {
try {
if (settings.initialDelayDuration) {
await sleep(
@@ -73,12 +72,14 @@ export class TaskWorker {
}
this.logger.info(`Task worker finished: ${this.taskId}`);
attemptNum = 0;
break;
} catch (e) {
attemptNum += 1;
this.logger.warn(
`Task worker failed unexpectedly, attempt number ${attemptNum}, ${e}`,
);
await sleep(Duration.fromISO('P1S'));
}
}
})();