mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 10:47:35 -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
27
pyscript.core/esm/runtime/_python.js
Normal file
27
pyscript.core/esm/runtime/_python.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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 */
|
||||
Reference in New Issue
Block a user