Skip to content

Commit

Permalink
pybricks.tools.run_task: call MICROPY_VM_HOOK_LOOP
Browse files Browse the repository at this point in the history
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: 5a0c7d5 ("pybricks/tools/pb_module_tools: remove gc_collect() from run loop")
  • Loading branch information
dlech committed Aug 24, 2024
1 parent 5dc34c1 commit a017bae
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pybricks/tools/pb_module_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment has been minimized.

Copy link
@laurensvalk

laurensvalk Sep 5, 2024

Member

Should this not be MICROPY_EVENT_POLL_HOOK? We want to be able to handle a pending SystemExit, for example.

Or perhaps rather add mp_handle_pending(true); since we don't necessarily want to __WFI?

This comment has been minimized.

Copy link
@laurensvalk

laurensvalk Sep 5, 2024

Member

Applied via bd7c345


if (loop_time == 0) {
continue;
Expand Down

0 comments on commit a017bae

Please sign in to comment.