8000 py/scheduler: Break out of the c task loop on re-schedule. · micropython/micropython@af4a8e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit af4a8e9

Browse files
committed
py/scheduler: Break out of the c task loop on re-schedule.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent 2a6bb79 commit af4a8e9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

py/scheduler.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,14 @@ static inline void mp_sched_run_pending(void) {
8888

8989
#if MICROPY_SCHEDULER_STATIC_NODES
9090
// Run all pending C callbacks.
91-
while (MP_STATE_VM(sched_head) != NULL) {
91+
bool pass_finished = false;
92+
while (MP_STATE_VM(sched_head) != NULL && !pass_finished) {
9293
mp_sched_node_t *node = MP_STATE_VM(sched_head);
9394
MP_STATE_VM(sched_head) = node->next;
9495
if (MP_STATE_VM(sched_head) == NULL) {
9596
MP_STATE_VM(sched_tail) = NULL;
97+
// ensure we exit even if a task re-scheduled in callback() below.
98+
pass_finished = true;
9699
}
97100
mp_sched_callback_t callback = node->callback;
98101
node->callback = NULL;

0 commit comments

Comments
 (0)
0