mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-22 19:53:00 -05:00
Worker sync utility (#1511)
* patched an issue with wasmoon randomly asking to resolve proxy references * simplified pyodide and micropython dance by grouping their common utilities together * created an integration test around a worker to main thread input between MicroPython and Lua * commented some weird bugs / funny behaviors around both MicroPython and Pyodide * other minor clean ups
This commit is contained in:
committed by
GitHub
parent
0cdbfbeb30
commit
af72e232c3
@@ -1,15 +1,17 @@
|
||||
import { clean, fetchPaths, stdio, writeFile } from "./_utils.js";
|
||||
import { fetchPaths, stdio } from "./_utils.js";
|
||||
import {
|
||||
run,
|
||||
runAsync,
|
||||
runEvent,
|
||||
runWorker,
|
||||
runWorkerAsync,
|
||||
writeFile,
|
||||
} from "./_python.js";
|
||||
|
||||
const type = "pyodide";
|
||||
|
||||
// REQUIRES INTEGRATION TEST
|
||||
/* c8 ignore start */
|
||||
const worker = (method) =>
|
||||
function (runtime, code, xworker) {
|
||||
globalThis.xworker = xworker;
|
||||
return this[method](runtime, `from js import xworker;${code}`);
|
||||
};
|
||||
|
||||
export default {
|
||||
type: [type, "py"],
|
||||
module: (version = "0.22.1") =>
|
||||
@@ -26,16 +28,11 @@ export default {
|
||||
}
|
||||
return runtime;
|
||||
},
|
||||
run: (runtime, code) => runtime.runPython(clean(code)),
|
||||
runAsync: (runtime, code) => runtime.runPythonAsync(clean(code)),
|
||||
runEvent(runtime, code, key) {
|
||||
return this.run(
|
||||
runtime,
|
||||
`import js;event=js.__events.get(${key});${code}`,
|
||||
);
|
||||
},
|
||||
runWorker: worker("run"),
|
||||
runWorkerAsync: worker("runAsync"),
|
||||
writeFile: ({ FS }, path, buffer) => writeFile(FS, path, buffer),
|
||||
run,
|
||||
runAsync,
|
||||
runEvent,
|
||||
runWorker,
|
||||
runWorkerAsync,
|
||||
writeFile,
|
||||
};
|
||||
/* c8 ignore stop */
|
||||
|
||||
Reference in New Issue
Block a user