← index #5795Issue #5947
Off-topic · high · value 1.131
QUERY · ISSUE

extmod/uasyncio Event.set() not safe in ISR

openby kevinkk525opened 2020-03-25updated 2020-04-07
extmod

If you call Event.set() in an ISR, you could end up losing all tasks that were awaiting the event (if the ISR is executed while uasyncio is sorting tasks on the queue e.g.).

I made a testscript a while ago to demonstrate this: https://gist.github.com/kevinkk525/5b89395604da3df3be7a015abcba04fa

CANDIDATE · ISSUE

uasyncio: feature request: multiple event loops

openby traversedaopened 2020-04-20updated 2023-02-10
extmod

I think this needs to go here and not in the micropython-libs repo...

A project I'm working on has two main contexts code can run in. Previously I had modeled those two contexts as two different event loops, with an explicit hand-off between them.

One loop was the "motion control" event loop. It was a higher priority and there were only specific spots it would be able to stop at safely. I could turn it into a blocking function (with the help of interrupts to handle some edge cases) but there are reasons why it's better for it to be co-operative multi-tasking based. The idea was that it would call motionLoop.stop() at regular intervals to allow the general loop to run.

The other loop was the general purpose loop which would run things like user plugins, a web interface, GC, etc.

Any thoughts?

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