-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I noticed this while looking at the source code.
Runtime.run
is marked async:
pyscript/pyscriptjs/src/runtime.ts
Lines 52 to 57 in aa85f5f
/** | |
* delegates the code to be run to the underlying interpreter | |
* (asynchronously) which can call its own API behind the scenes. | |
* Python exceptions are turned into JS exceptions. | |
* */ | |
abstract run(code: string): Promise<any>; |
But then when we call pyodide we do the following:
pyscript/pyscriptjs/src/pyodide.ts
Lines 69 to 71 in aa85f5f
async run(code: string): Promise<any> { | |
return await this.interpreter.runPythonAsync(code); | |
} |
Note the return await
, which should probably be just a return
. I'm not fully sure of the implications of doing the await
here but I guess it causes code to be less parallel that it should be.
I think that it means that if we do the following:
await Promise.all([
runtime.run(src1),
runtime.run(src2),
runtime.run(src3)
]);
src1, src2 and src3 will not be executed in parallel but sequentially.
In general, I think we have a problem with our usage of async in our codebase: we use them a bit too freely and without really understanding what's going on (or at least: personally I don't fully understand what's going on: if you do, please explain to me :)).
Metadata
Metadata
Assignees
Labels
Type
Projects
Status