Skip to content

Commit ba7b32e

Browse files
committed
fixed error related to the field
we're using the field `data` for the postMessage whereas the example we based it off of uses `python`. updated to fix the error
1 parent c3fb927 commit ba7b32e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

app/utils/pyodide/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export const plotTestPlot = async (worker: Worker | null) => {
117117
}
118118
// TODO: Figure out how to get image results from pyodide
119119
return worker.postMessage({
120-
data: `plt.plot([1,2,3,4])`,
120+
data: `print('hello world')`,
121121
});
122122
};
123123

app/utils/pyodide/webworker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ self.onmessage = async (event) => {
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:
19-
const { python, ...context } = event.data;
19+
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];
2323
}
2424
// Now is the easy part, the one that is similar to working in the main thread:
2525
try {
2626
self.postMessage({
27-
results: await self.pyodide.runPythonAsync(python),
27+
results: await self.pyodide.runPythonAsync(data),
2828
});
2929
} catch (error) {
3030
self.postMessage({ error: error.message });

0 commit comments

Comments
 (0)