Content-Length: 331438 | pFad | http://github.com/micropython/micropython/commit/3f34be69c77dfbd1533af1f04ea460d7da2d118a

E0 webassembly/asyncio: Fix case where a Promise is resolved with no arg. · micropython/micropython@3f34be6 · GitHub
Skip to content

Commit 3f34be6

Browse files
committed
webassembly/asyncio: Fix case where a Promise is resolved with no arg.
Signed-off-by: Damien George <damien@micropython.org>
1 parent c37eb93 commit 3f34be6

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

ports/webassembly/asyncio/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, thenable):
7575
self.waiting = None # Task waiting on completion of this thenable
7676
thenable.then(self.set)
7777

78-
def set(self, value):
78+
def set(self, value=None):
7979
# Thenable/Promise is fulfilled, set result and schedule any waiting task.
8080
self.result = value
8181
if self.waiting:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Test an asyncio task await'ing on a Promise that's resolved without an argument.
2+
3+
const mp = await (await import(process.argv[2])).loadMicroPython();
4+
5+
globalThis.foo = new Promise((resolve) => {
6+
console.log(1);
7+
resolve(); // resolve without an argument
8+
console.log(2);
9+
});
10+
11+
mp.runPython(`
12+
import asyncio
13+
import js
14+
15+
async def task():
16+
print(3)
17+
print(await js.foo)
18+
print(4)
19+
20+
asyncio.create_task(task())
21+
`);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1
2+
2
3+
3
4+
None
5+
4

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/micropython/micropython/commit/3f34be69c77dfbd1533af1f04ea460d7da2d118a

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy