Skip to content

Commit

Permalink
add is_running var
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Nov 18, 2024
1 parent 966ba54 commit 669eaa0
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions script/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ let token;
let isReady = false;
let toggleStatus = 1;
let theme = "dark";
let is_running = false;

// Global variables
var Module = {
Expand Down Expand Up @@ -124,10 +125,9 @@ const displayOutput = (text) => {
const displayError = (text) => {
console.error("Error: ", text);

// TODO: Ignore keepRuntimeAlive() warning
if (text === "program exited (with status: 2), but keepRuntimeAlive() is set (counter=0) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)") {
return;
}
// if (text === "program exited (with status: 2), but keepRuntimeAlive() is set (counter=0) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)") {
// return;
// }

elm_error.textContent += text + "<br>";
};
Expand Down Expand Up @@ -230,14 +230,16 @@ const showErrorInIframe = () => {
const captureLint = (arguments) => {
console.log("Capture Lint: ", arguments);

if (keepRuntimeAlive && keepRuntimeAlive()) {
if (is_running) {
return null;
}

elm_output.textContent = "";
elm_error.textContent = "";

try {
is_running = true;

const exitCode = callMain(arguments);

if (exitCode !== 0) {
Expand All @@ -247,13 +249,15 @@ const captureLint = (arguments) => {
}
} catch (err) {
return null;
} finally {
is_running = false;
}
};

const captureOutput = (showOutput, arguments) => {
console.log("Capture Output: ", arguments);

if (keepRuntimeAlive && keepRuntimeAlive()) {
if (is_running) {
return;
}

Expand All @@ -265,6 +269,8 @@ const captureOutput = (showOutput, arguments) => {
}

try {
is_running = true;

const exitCode = callMain(arguments);

if (exitCode !== 0) {
Expand All @@ -285,9 +291,10 @@ const captureOutput = (showOutput, arguments) => {
elm_error.innerHTML = "خطای غیرمنتظره رخ داد.<br>" + err;
showErrorInIframe();
} finally {
if (Module.noInitialRun) {
// restartRuntime();
}
is_running = false;
// if (Module.noInitialRun) {
// restartRuntime();
// }
}
};

Expand Down

0 comments on commit 669eaa0

Please sign in to comment.