← index #8937Issue #5798
Related · high · value 2.531
QUERY · ISSUE

extmod/uasyncio: gather gets stuck if you pass an empty list in v1.19

openby frlryropened 2022-07-20updated 2022-12-26
bugextmod

Hello, folks

This is pretty straightforward in v1.17 and v1.18 passing an empty list to gather will return (or yield) whereas in v1.19 it gets stuck for ever. Not sure if this is a new intended behavior (which is not in the docs?). I'm assuming this is a bug as there is nothing in the release notes.

Cheers,

CANDIDATE · ISSUE

extmod uasyncio: Cancelling a gather only cancels one task instead of all

closedby kevinkk525opened 2020-03-25updated 2022-03-30
bug

This is easy to explain, cancelling a gather(...) will only cancel one task, the remaining ones still continue.

Testcase:

async def test_gather_cancel_itself():
    res = []

    async def consumer():
        nonlocal res
        try:
            await asyncio.sleep(1)
        except asyncio.CancelledError:
            dprint("wait() cancelled")
            res.append(True)
        else:
            res.append(False)

    async def gather():
        t = []
        for _ in range(5):
            t.append(asyncio.create_task(consumer()))
        try:
            await asyncio.gather(*t)
        except asyncio.CancelledError:
            print("gather cancelled")

    t = asyncio.create_task(gather())
    await asyncio.sleep(0.1)
    t.cancel()
    await asyncio.sleep(1.5)
    return res

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied