Skip to content

Asyncio task creation and cancellation problem #16253

Discussion options

You must be logged in to vote

The task class in Python has the cancelled method but in micropython it does not, and has a much smaller set of methods. Have a look by adding print(dir(task)) to the Superfast code snippet and then run it in normal python and then run the code again in micropython, but deleting the print(f'canceled: {task.cancelled()}') line which will cause micropython to hiccup. You can then see the python / micropython differences for async tasks

In your own code snippet I think the likes of task1 = asyncio.run(blink_red(house_red)) looks wrong. I'm no expert, but I think you should only run one asyncio.run loop (i.e the async def test() function in your snippet). I've only created and run tasks with …

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
7 replies
@beetlegigg
Comment options

@davefes
Comment options

@davefes
Comment options

@beetlegigg
Comment options

@davefes
Comment options

Answer selected by davefes
Comment options

You must be logged in to vote
2 replies
@davefes
Comment options

@davefes
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants