get unstuck
This commit is contained in:
parent
0c070c5aec
commit
ffc071adbb
1 changed files with 12 additions and 6 deletions
12
site.js
12
site.js
|
@ -71,17 +71,23 @@ async function rounder(users, data, mode) {
|
|||
let p = [];
|
||||
let congested = [];
|
||||
let timeout = false;
|
||||
setTimeout(function() {
|
||||
|
||||
let pr = new Promise(resolve => setTimeout(function (...ag) {
|
||||
timeout = true;
|
||||
},(process.env.delay*1000) || (60*1000));
|
||||
resolve(ag);
|
||||
}, (process.env.delay * 1000) || (60 * 1000)))
|
||||
|
||||
for (let u of users) {
|
||||
if (timeout) break;
|
||||
let it = 0;
|
||||
while (p.length >= (process.env.maxRate || 15)) {
|
||||
p = p.filter(x => x != 'hi');
|
||||
if (timeout) {
|
||||
console.warn(`Somehow, this is stuck.`);
|
||||
break;
|
||||
}
|
||||
if (p.length == 0) break;
|
||||
let pv = await Promise.any(p);
|
||||
let pv = await Promise.any([...p,pr]);
|
||||
it++;
|
||||
if (it > 10) {
|
||||
console.warn(`Promises got congested. Moving to another array...`)
|
||||
|
|
Loading…
Reference in a new issue