Skip to content

run_cast_example: end a board run from the top level - #199

Merged
bdbarnett merged 1 commit into
mainfrom
cast-run-ends
Oct 9, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
cast-run-ends

Conversation

@bdbarnett

Copy link
Copy Markdown
Collaborator

On a board, tools/run_cast_example.py ended a timed run by calling machine.soft_reset() from inside the display's show(). There show() runs from a callback (the app's refresh timer, or an LVGL flush), and an exception raised in a callback is printed and dropped. Since #158 the flush always ends, so the board no longer freezes, but the SystemExit no longer ends the run either: after the CAST line the example just keeps going.

Now the runner holds the main thread once the example's script body returns, reports when SECONDS are up, and soft-resets from its own top level, outside any callback. An example that loops in its own body is unwound by an exception raised from show() back to the runner, which soft-resets the same way. Desktop runs are unchanged.

Run on an ESP32-P4 through the Roku Companion channel (roku), 30 s, with display_driver from pydevices main:

Example This branch main
lv_test_timer (LVGL) CAST 31.7 s after the display came up, MPY: soft reboot 0.4 s later, app gone SystemExit printed from _flush_cb_direct, app still reporting at 116 s
testris (appdev) CAST at 32.0 s, soft reboot 0.4 s later, app gone SystemExit printed from multimer's timer, app still loaded

"App gone" was checked on both consoles (UART and USB CDC) without resetting the board: board_config was no longer in sys.modules, and the REPL answered.

On a board the runner ended a timed run by calling machine.soft_reset() from
inside the display's show(). show() runs from a callback there (the app's
refresh timer, or an LVGL flush), and anything raised in a callback is printed
and dropped. Now that display_driver's flush always ends (#158), the
SystemExit no longer freezes the board but no longer ends the run either: the
example kept running after its CAST line.

The runner now holds the main thread once the example's script body returns,
reports when SECONDS are up, and soft-resets from its own top level. An
example that loops in its own body is unwound by an exception raised from
show() back to the runner, which then soft-resets the same way.
@bdbarnett
bdbarnett merged commit d434d6f into main Oct 9, 2026
2 checks passed
@bdbarnett
bdbarnett deleted the cast-run-ends branch October 9, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant