Skip to content
This repository was archived by the owner on Jun 6, 2023. It is now read-only.

Commit 823ace5

Browse files
committed
decrease max polling interval and add repeats to jobs logs polling
1 parent 488a8b7 commit 823ace5

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

lib/jobs/logs.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ function logs(params, cb) {
7373
if (typeof params.line === 'undefined') params.line = 0;
7474
else singleChunk = true; // if line is specified only a limited chunk will be returned; params.limit defines the limit; default is 2000
7575
var backoff = 0;
76+
var backoff_repeat = 0;
7677
var allLogs;
7778
if (!global.paperspace_cli || json) allLogs = [];
7879

79-
var MAX_BACKOFF_SECS = 30;
80+
var MAX_BACKOFF_SECS = 5;
81+
var BACKOFF_REPEATS = 10;
8082

8183
function _logs() {
8284
return method(logs, params, function logsCb(err, data) {
@@ -87,11 +89,24 @@ function logs(params, cb) {
8789
params.line = result.line;
8890
}
8991
if ((result.count > 0 || tail) && !result.eof && !singleChunk) {
90-
if (result.count > 0) backoff = 0;
92+
if (result.count > 0) {
93+
backoff = 0;
94+
backoff_repeat = 0;
95+
}
9196
else if (backoff < MAX_BACKOFF_SECS) {
9297
// increase backoff geometrically
93-
if (backoff === 0) backoff = 1;
94-
else backoff *= 2;
98+
if (backoff === 0) {
99+
backoff = 0.2;
100+
backoff_repeat = 0;
101+
}
102+
else if (backoff_repeat < BACKOFF_REPEATS) {
103+
backoff_repeat += 1;
104+
}
105+
else {
106+
backoff_repeat = 0;
107+
if (backoff > 1 && backoff < 2) backoff = 1;
108+
backoff *= 2;
109+
}
95110
}
96111
else backoff = MAX_BACKOFF_SECS; // cap backoff at this
97112

0 commit comments

Comments
 (0)