Skip to content

Commit

Permalink
Reject submission in case of no judger
Browse files Browse the repository at this point in the history
  • Loading branch information
dungwinux committed Apr 1, 2019
1 parent 5d39ea6 commit 3725cc3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/controller/submitCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,29 @@ async function sendCode(source_code_path, user_id, prob_name) {
judger = kon.judgers[judgerNum];
}

let retry = 3;
let offset = 30000;
let delay = 30000;
let timeout = 120000;

judger
.send(source_code_path, prob_name, sub_id)
.then((res) => {
if (res.status !== 200) throw Error("Cannot get from Kon");
})
.then(() => {
let retry = 3;
let offset = 30000;
let delay = 30000;
let timeout = 120000;

// Attempt & retry 2 times to get submission
for (let attempt = 0; attempt < retry; attempt++) {
let time = offset + attempt * delay;
if (time < timeout) setTimeout(reloadSub, time, judger);
}
// Set "Timeout" status on submission after timeout
setTimeout(updateSubmission, timeout, sub_id, "Timeout", null);
})
.catch((err) => {
Console.log(err.message);
updateSubmission(sub_id, "Cannot judge", null);
})
.finally(() => {
// Set "Timeout" status on submission after timeout
setTimeout(updateSubmission, timeout, sub_id, "Timeout", null);
});
} catch (err) {
Console.log(err.message);
Expand Down

0 comments on commit 3725cc3

Please sign in to comment.