Skip to content

Commit d40e6a3

Browse files
committed
set a critical section for when code is executing
1 parent fdc2b7f commit d40e6a3

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

‎v3/js/opt-frontend-common.js‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ function genericOptFrontendReady() {
106106
"Report a bug to philip@pgbovine.net\n\n" +
107107
"(Click the 'Generate URL' button to include a unique URL in your email bug report.)");
108108

109-
$('#executeBtn').html("Visualize Execution");
110-
$('#executeBtn').attr('disabled', false);
111-
112-
isExecutingCode = false; // ugh, nasty global
109+
doneExecutingCode();
113110
});
114111
}
115112

@@ -220,8 +217,7 @@ function updateAppDisplay() {
220217
$("#pyOutputPane,#surveyHeader").show();
221218
$("#embedLinkDiv").show();
222219

223-
$('#executeBtn').html("Visualize Execution");
224-
$('#executeBtn').attr('disabled', false);
220+
doneExecutingCode();
225221

226222
// do this AFTER making #pyOutputPane visible, or else
227223
// jsPlumb connectors won't render properly
@@ -263,11 +259,15 @@ function handleUncaughtExceptionFunc(trace) {
263259
pyInputCodeMirror.on('change', f);
264260
}
265261

266-
$('#executeBtn').html("Visualize Execution");
267-
$('#executeBtn').attr('disabled', false);
262+
doneExecutingCode();
268263
}
269264
}
270265

266+
function doneExecutingCode() {
267+
$('#executeBtn').html("Visualize Execution");
268+
$('#executeBtn').attr('disabled', false);
269+
isExecutingCode = false; // nasty global
270+
}
271271

272272
function enterDisplayMode() {
273273
$(document).scrollTop(0); // scroll to top to make UX better on small monitors
@@ -358,11 +358,6 @@ function executePythonCode(pythonSourceCode,
358358

359359
handleSuccessFunc();
360360
}
361-
362-
// WARNING: this line may run before handleSuccessFunc or
363-
// handleUncaughtExceptionFunc fully finishes if they
364-
// contain asynchronous parts
365-
isExecutingCode = false;
366361
},
367362
"json");
368363
}

0 commit comments

Comments
 (0)