Skip to content

Commit 5568937

Browse files
committed
Improve catching time limit exceeded
1 parent f908960 commit 5568937

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/languages/Exeutor.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ class Executor extends Commander {
1414

1515
execute(tempPath, command) {
1616
const containerName = uuid.v4();
17-
let timer = setTimeout(() => {
18-
timer = null;
19-
execute(`docker kill ${containerName}`, this.cwd);
17+
let killed = false;
18+
const timer = setTimeout(() => {
19+
execute(`docker kill ${containerName}`, this.cwd).then(() => {
20+
killed = true;
21+
});
2022
}, timeLimit);
2123
return execute([
2224
`docker run --rm`,
@@ -30,13 +32,9 @@ class Executor extends Commander {
3032
'/bin/bash -c',
3133
`"${command}"`,
3234
].join(' '), this.cwd).catch(error => {
33-
if (timer) {
34-
clearTimeout(timer);
35-
} else {
36-
console.error('Time Limit Exceeded');
37-
}
35+
if (killed) console.error('Time Limit Exceeded');
3836
throw error;
39-
});
37+
}).finally(() => clearTimeout(timer));
4038
}
4139

4240
compile(tempPath) {

src/languages/cpp/builder/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ set_target_properties(tracers
7474
return { name, content };
7575
});
7676

77-
export default builder;
77+
export default builder;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy