Skip to content

Commit 73bccee

Browse files
committed
Explore loading the Pyodide worker...
1 parent 42a3c97 commit 73bccee

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Start a timer
2+
const initializeWebRTimerStart = performance.now();
3+
4+
5+
// Encase with a dynamic import statement
6+
globalThis.qpyodideInstance = await import(
7+
qpyodideCustomizedPyodideOptions.indexURL + "pyodide.mjs").then(
8+
async({ loadPyodide }) => {
9+
10+
console.log("Start loading Pyodide");
11+
// Populate Pyodide options with defaults or new values based on `pyodide`` meta
12+
let loadedPyodide = await loadPyodide(
13+
qpyodideCustomizedPyodideOptions
14+
);
15+
16+
globalThis.mainPyodide = loadedPyodide;
17+
18+
mainPyodide.runPython("globalScope = {}");
19+
console.log("Completed loading Pyodide");
20+
return mainPyodide;
21+
22+
});
23+
24+
// Stop timer
25+
const initializeWebRTimerEnd = performance.now();
26+
27+
// Create a function to retrieve the promise object.
28+
globalThis._qpyodideGetInstance = function() {
29+
return qpyodideInstance;
30+
}

0 commit comments

Comments
 (0)