uasyncio V3 exception detect problem.
Posted: Tue Jun 16, 2020 6:48 am
How to correctly implement the following code for the V3 version?
V2
V3
it works, but how detect error ?
Thanks.
V2
Code: Select all
loop = uasyncio.get_event_loop()
loop.create_task(lst_service())
loop.create_task(ble_service())
try:
loop.run_forever()
except Exception as e:
print("error: "+str(e))
Code: Select all
async def main():
tasks = (uart_xbee_service, uart_gps_service)
try:
res = await uasyncio.funcs.gather(*tasks, return_exceptions=True)
except uasyncio.CancelledError:
print("Cancelled.")
except Exception as e:
print("error")
try:
uasyncio.run(main())
except Exception as e: # not working ?
print("error: "+str(e))
Thanks.