Skip to content

Commit

Permalink
Fix the program being unstoppable when waiting for stdin
Browse files Browse the repository at this point in the history
If we send a ‘stopPython’ message which the web worker is in the
while (true) loop, it won’t handle the message until after the loop
exits, so we need to use Pyodide’s interruptBuffer method for checking
if we’ve stopped rather than just checking the ‘stopped’ global.
  • Loading branch information
tuzz committed Jan 24, 2024
1 parent 1f10b84 commit 80a512f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pyodide/webworker.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const readFromStdin = (bufferToWrite) => {
postMessage({ method: "handleInput" });

while (true) {
checkIfStopped();
pyodide.checkInterrupt();
const result = Atomics.wait(stdinBuffer, 0, previousLength, 100);
if (result === "not-equal") { break; }
}
Expand Down

0 comments on commit 80a512f

Please sign in to comment.