-
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Need to use backoff code for all "Tasks" calls:
const BACKOFF_WAIT_START = 1; // ms
const DEFAULT_MAX_TOTAL_WAIT = 1000; // ms
function runWithBackoff(func, max_total_wait) {
max_total_wait = max_total_wait ?? DEFAULT_MAX_TOTAL_WAIT;
let ms = BACKOFF_WAIT_START;
let total = 0;
while (true) {
try {
return func();
} catch(err) {
if (total < max_total_wait) {
Utilities.sleep(ms);
total += ms;
ms = ms * 2;
} else {
throw new Error("After waiting " + total + "ms: " + err.message);
}
}
}
}
Metadata
Metadata
Assignees
Labels
No labels