From 3e33d88373f03e7d50aef0635f4891ccdcfb786f Mon Sep 17 00:00:00 2001 From: Dexter Chua Date: Sat, 9 Jan 2021 00:28:03 +0800 Subject: [PATCH] Remove dataLoadPromise in pyodide.js (#1075) This is not necessary, because postRun is not run until all dependencies are satisfied. Since the definition of Module.postRun is slightly modified here, I took the opportunity to convert it to use async/await. --- src/pyodide.js | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/src/pyodide.js b/src/pyodide.js index c7e235aa8..e3f8025e6 100644 --- a/src/pyodide.js +++ b/src/pyodide.js @@ -362,31 +362,15 @@ var languagePluginLoader = new Promise((resolve, reject) => { }; Module.locateFile = (path) => baseURL + path; - var postRunPromise = new Promise((resolve, reject) => { - Module.postRun = () => { - delete self.Module; - fetch(`${baseURL}packages.json`) - .then((response) => response.json()) - .then((json) => { - fixRecursionLimit(self.pyodide); - self.pyodide = makePublicAPI(self.pyodide, PUBLIC_API); - self.pyodide._module.packages = json; - resolve(); - }); - }; - }); - - var dataLoadPromise = new Promise((resolve, reject) => { - Module.monitorRunDependencies = - (n) => { - if (n === 0) { - delete Module.monitorRunDependencies; - resolve(); - } - } - }); - - Promise.all([ postRunPromise, dataLoadPromise ]).then(() => resolve()); + Module.postRun = async () => { + delete self.Module; + let response = await fetch(`${baseURL}packages.json`); + let json = await response.json(); + fixRecursionLimit(self.pyodide); + self.pyodide = makePublicAPI(self.pyodide, PUBLIC_API); + self.pyodide._module.packages = json; + resolve(); + }; const scriptSrc = `${baseURL}pyodide.asm.js`; loadScript(scriptSrc, () => {