Files
pyscript/pyscript.core/esm/runtime/_python.js
Andrea Giammarchi af72e232c3 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
2023-06-08 11:10:47 +02:00

28 lines
824 B
JavaScript

import { clean, writeFile as writeFileUtil } from "./_utils.js";
// REQUIRES INTEGRATION TEST
/* c8 ignore start */
export const run = (runtime, code) => runtime.runPython(clean(code));
export const runAsync = (runtime, code) => runtime.runPythonAsync(clean(code));
export function runEvent(runtime, code, key) {
code = `import js;event=js.__events.get(${key});${code}`;
return this.run(runtime, code);
}
const worker = (method) =>
function (runtime, code, xworker) {
code = `from js import xworker;${code}`;
globalThis.xworker = xworker;
return this[method](runtime, code);
};
export const runWorker = worker("run");
export const runWorkerAsync = worker("runAsync");
export const writeFile = ({ FS }, path, buffer) =>
writeFileUtil(FS, path, buffer);
/* c8 ignore stop */