mirror of https://github.com/pyodide/pyodide.git
Merge pull request #272 from mdboom/package-loading-race-condition
Fix package loading race condition
This commit is contained in:
commit
1984cc5688
|
@ -148,8 +148,14 @@ var languagePluginLoader = new Promise((resolve, reject) => {
|
|||
messageCallback(`Loading ${packageList}`);
|
||||
}
|
||||
|
||||
window.pyodide._module.monitorRunDependencies = (n) => {
|
||||
if (n === 0) {
|
||||
// monitorRunDependencies is called at the beginning and the end of each
|
||||
// package being loaded. We know we are done when it has been called
|
||||
// exactly "toLoad * 2" times.
|
||||
var packageCounter = Object.keys(toLoad).length * 2;
|
||||
|
||||
window.pyodide._module.monitorRunDependencies = () => {
|
||||
packageCounter--;
|
||||
if (packageCounter === 0) {
|
||||
for (let package in toLoad) {
|
||||
window.pyodide.loadedPackages[package] = toLoad[package];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue