Skip to content

Commit 510d4a3

Browse files
committed
Fix issues noted during MicroPython v1.19.1 merge.
gather is now async, and the one `yield` that was in it was replaced by `await core._never()`. Incorporated adafruit/circuitpython@55169e0#diff-01b6761622028d47c6d1c2293fa365de3d8f03feb485d42e42ea9050198e1635 which never got into the asyncio library previously. (I fixed the bug independently, but didn't understand why it was needed, until I found that PR.)
1 parent 9d69aa2 commit 510d4a3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

asyncio/funcs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def wait_for(aw, timeout, sleep=core.sleep):
5959
# Wait for the timeout to elapse.
6060
await sleep(timeout)
6161
except core.CancelledError as er:
62-
status = er.value
62+
status = er.args[0] if er.args else None
6363
if status is None:
6464
# This wait_for was cancelled externally, so cancel aw and re-raise.
6565
runner_task.cancel()
@@ -92,7 +92,7 @@ def remove(t):
9292
pass
9393

9494

95-
def gather(*aws, return_exceptions=False):
95+
async def gather(*aws, return_exceptions=False):
9696
"""Run all *aws* awaitables concurrently. Any *aws* that are not tasks
9797
are promoted to tasks.
9898
@@ -134,7 +134,7 @@ def done(t, er):
134134
# Wait for the a sub-task to need attention.
135135
gather_task.data = _Remove
136136
try:
137-
yield
137+
await core._never()
138138
except core.CancelledError as er:
139139
cancel_all = True
140140
state = er

asyncio/task.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,12 @@ def __iter__(self):
167167

168168
def __next__(self):
169169
if not self.state:
170-
# Task finished, raise return value to caller so it can continue.
171-
raise self.data
170+
if self.data is None:
171+
# Task finished but has already been sent to the loop's exception handler.
172+
raise StopIteration
173+
else:
174+
# Task finished, raise return value to caller so it can continue.
175+
raise self.data
172176
else:
173177
# Put calling task on waiting queue.
174178
self.state.push(core.cur_task)

0 commit comments

Comments
 (0)