Commit 4781a822 authored by ThorbenQuast's avatar ThorbenQuast
Browse files

editor: add timeout (10seconds) to handle cases in which the initialization of executions fails

(e.g. "execute" is not posted or "start" is not sent back from the workspace)
parent acde154f
......@@ -9,9 +9,11 @@ var CodeEditorOutput = Emitter.extend({
this.temporaryText = "";
this.appendInterval = null;
this.preNode = null;
this.failedExecuteTimeOut = null;
this.running = false;
this.preNode = null;
this.running = false; //execute command has been fired?
this.hasStarted = false; //stream in WS gas started?
},
setup: function(node) {
......@@ -56,6 +58,9 @@ var CodeEditorOutput = Emitter.extend({
// register events
this.view.onSocket("start", function(data) {
clearTimeout(self.failedExecuteTimeOut);
self.failedExecuteTimeOut = null;
self.hasStarted = true;
var autoClear = self.view.getPreference("autoClear");
self.textSet = self.textSet && !autoClear;
self.append(
......@@ -71,13 +76,16 @@ var CodeEditorOutput = Emitter.extend({
}).onSocket("done", function(data) {
clearInterval(self.appendInterval);
self.appendInterval = null;
self.append(); //append the remaining temporaries
self.append(
"\n--------------------\n" +
(data.aborted ? "process was aborted!\n" : "") +
"runtime: " + self.formatRuntime(data.runtime) + "\n" +
"====================\n\n\n");
if (self.hasStarted) {
self.append(); //append the remaining temporaries
self.append(
"\n--------------------\n" +
(data.aborted ? "process was aborted!\n" : "") +
"runtime: " + self.formatRuntime(data.runtime) + "\n" +
"====================\n\n\n");
}
self.running = false;
self.hasStarted = false;
self.updateExeButtons();
});
......@@ -150,13 +158,20 @@ var CodeEditorOutput = Emitter.extend({
self.view.POST("execute", {
cmd: cmd,
base: filePath
}).done(function(res) { //double check for running jobs
if (!res.success) {
self.view.alert("There is already a running job!");
}
});
});
var handleFail = function() {
self.abort();
self.append(
"\n--------------------\n" +
"Initialization has failed, please try again.\n" +
"====================\n\n\n");
self.running = false;
self.updateExeButtons();
};
//extra timeout (10s) if the "start" is not sent back/ websockets fail
self.failedExecuteTimeOut = setTimeout(handleFail, 10000);
});
return this;
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment