From a017bae12586535eb6b8b80495fb9fc55dc89802 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sat, 24 Aug 2024 17:14:18 -0500 Subject: [PATCH] pybricks.tools.run_task: call MICROPY_VM_HOOK_LOOP Since removing the gc_collect() from the run_task() loop, when setting loop_time_ms to 0, it was possible that the contiki events were never getting handled, causing random crashes due to watchdog timeout or UART device failure. This adds MICROPY_VM_HOOK_LOOP in the loop to ensure that background events are always being handled even when running in a tight loop. Fixes: 5a0c7d594 ("pybricks/tools/pb_module_tools: remove gc_collect() from run loop") --- pybricks/tools/pb_module_tools.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pybricks/tools/pb_module_tools.c b/pybricks/tools/pb_module_tools.c index 866232260..1976d52f6 100644 --- a/pybricks/tools/pb_module_tools.c +++ b/pybricks/tools/pb_module_tools.c @@ -238,6 +238,7 @@ static mp_obj_t pb_module_tools_run_task(size_t n_args, const mp_obj_t *pos_args if (nlr_push(&nlr) == 0) { while (mp_iternext(iterable) != MP_OBJ_STOP_ITERATION) { + MICROPY_VM_HOOK_LOOP if (loop_time == 0) { continue;