mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Use seperate VM for interactive shell
This commit is contained in:
1 parent
669aa70aab
commit
264d218b70
1 file changed
+4
-3
@@ -93,6 +93,9 @@ function print_to_console(data) {
|
||||
term.write(remove_non_ascii(data) + "\r\n");
|
||||
}
|
||||
|
||||
const terminalVM = rp.vmStore.init("term_vm");
|
||||
terminalVM.setStdout(print_to_console);
|
||||
|
||||
var input = "";
|
||||
term.on("data", (data) => {
|
||||
const code = data.charCodeAt(0);
|
||||
@@ -103,9 +106,7 @@ term.on("data", (data) => {
|
||||
} else {
|
||||
term.write("\r\n");
|
||||
try {
|
||||
rp.pyEval(input, {
|
||||
stdout: print_to_console
|
||||
});
|
||||
terminalVM.exec(input);
|
||||
} catch (err) {
|
||||
if (err instanceof WebAssembly.RuntimeError) {
|
||||
err = window.__RUSTPYTHON_ERROR || err;
|
||||
|
||||
Reference in new issue
Block a user