diff options
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/py/runtime.c b/py/runtime.c index 2a07df664..02b866d83 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -65,7 +65,15 @@ void mp_init(void) { // no pending exceptions to start with MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_NULL; #if MICROPY_ENABLE_SCHEDULER - MP_STATE_VM(sched_state) = MP_SCHED_IDLE; + #if MICROPY_SCHEDULER_STATIC_NODES + if (MP_STATE_VM(sched_head) == NULL) { + // no pending callbacks to start with + MP_STATE_VM(sched_state) = MP_SCHED_IDLE; + } else { + // pending callbacks are on the list, eg from before a soft reset + MP_STATE_VM(sched_state) = MP_SCHED_PENDING; + } + #endif MP_STATE_VM(sched_idx) = 0; MP_STATE_VM(sched_len) = 0; #endif |