kopia lustrzana https://github.com/micropython/micropython
webassembly/asyncio: Fix case where a Promise is resolved with no arg.
Signed-off-by: Damien George <damien@micropython.org>
rodzic
521b4280c9
commit
0a07cd8a91
|
@ -75,7 +75,7 @@ class ThenableEvent:
|
|||
self.waiting = None # Task waiting on completion of this thenable
|
||||
thenable.then(self.set)
|
||||
|
||||
def set(self, value):
|
||||
def set(self, value=None):
|
||||
# Thenable/Promise is fulfilled, set result and schedule any waiting task.
|
||||
self.result = value
|
||||
if self.waiting:
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// Test an asyncio task await'ing on a Promise that's resolved without an argument.
|
||||
|
||||
const mp = await (await import(process.argv[2])).loadMicroPython();
|
||||
|
||||
globalThis.foo = new Promise((resolve) => {
|
||||
console.log(1);
|
||||
resolve(); // resolve without an argument
|
||||
console.log(2);
|
||||
});
|
||||
|
||||
mp.runPython(`
|
||||
import asyncio
|
||||
import js
|
||||
|
||||
async def task():
|
||||
print(3)
|
||||
print(await js.foo)
|
||||
print(4)
|
||||
|
||||
asyncio.create_task(task())
|
||||
`);
|
|
@ -0,0 +1,5 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
None
|
||||
4
|
Ładowanie…
Reference in New Issue