···117117 }
118118 // TODO: Figure out how to get image results from pyodide
119119 return worker.postMessage({
120120- data: `plt.plot([1,2,3,4])`,
120120+ data: `print('hello world')`,
121121 });
122122};
123123
+2-2
app/utils/pyodide/webworker.js
···1616 // make sure loading is done
1717 await pyodideReadyPromise;
1818 // Don't bother yet with this line, suppose our API is built in such a way:
1919- const { python, ...context } = event.data;
1919+ const { data, ...context } = event.data;
2020 // The worker copies the context in its own "memory" (an object mapping name to values)
2121 for (const key of Object.keys(context)) {
2222 self[key] = context[key];
···2424 // Now is the easy part, the one that is similar to working in the main thread:
2525 try {
2626 self.postMessage({
2727- results: await self.pyodide.runPythonAsync(python),
2727+ results: await self.pyodide.runPythonAsync(data),
2828 });
2929 } catch (error) {
3030 self.postMessage({ error: error.message });