Content-Length: 324694 | pFad | http://github.com/algorithm-visualizer/tracers.js/commit/5568937414393152c0e3426c3df350d068b01c75

19 Improve catching time limit exceeded · algorithm-visualizer/tracers.js@5568937 · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/algorithm-visualizer/tracers.js/commit/5568937414393152c0e3426c3df350d068b01c75

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy