Skip to content
Discussion options

You must be logged in to vote

@bjpirt As long as you only run a single event loop, there's no problem. (@andrewleech -- asyncio doesn't know about threads and doesn't have any thread-local storage, it doesn't care which thread it's running on).

That said, you need to be very careful that you do not access/modify any asyncio internal state concurrently (e.g. from another thread or interrupt handler). e.g. you may not call create_task from other threads, or Event.set, while asyncio is running (on any thread). MicroPython has asyncio.ThreadSafeFlag which you can use to safely signal into asyncio from another thread or interrupt handler.

Replies: 4 comments 3 replies

Comment options

andrewleech
Sep 12, 2023
Collaborator Sponsor

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

Answer selected by bjpirt
@andrewleech
Comment options

andrewleech Sep 13, 2023
Collaborator Sponsor

Comment options

You must be logged in to vote
1 reply
@bjpirt
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

andrewleech
Sep 21, 2023
Collaborator Sponsor

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants