Uasyncio gather questions

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
vahithosan
Posts: 19
Joined: Wed Jul 26, 2017 5:15 pm

Uasyncio gather questions

Post by vahithosan » Wed May 04, 2022 7:14 am

Hi. I have a problem. At the beginning, I run 2 tasks with gather.

Code: Select all

async def ana_sayfa_as(r, ayar):
    pb.press_func(False)
    pb.release_func(menu,)
    pb.long_func(gizli_menu,)
    sb.press_func(seri,)
    tb.press_func(tek_at,)


async def main():
    global a1
    global t1
    t1 = uasyncio.create_task(rotar(r, ayar))
    a1 = uasyncio.create_task(ana_sayfa_as(r, ayar))
    await uasyncio.gather(t1,a1)
    
uasyncio.run(main())
MicroPython 2ea21ab-dirty on 2022-05-01; ESP32 module with ESP32
I was able to cancel the "ana_sayfa" task when I pressed the button with the firmware.

With recent changes in git repo I can't anymore. i am getting error like this

Code: Select all

File "uasyncio/funcs.py", line 1, in gather File "uasyncio/core.py", line 1, in run_until_complete File "main.py", CancelledError:
https://github.com/micropython/micropyt ... 3c3ef2a38d

I looked here but I don't understand

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Uasyncio gather questions

Post by pythoncoder » Wed May 04, 2022 9:57 am

See this tutorial section which describes the behaviour. It seems it is now behaving correctly.
Peter Hinch
Index to my micropython libraries.

Post Reply