Skip to content

Commit

Permalink
shared/runtime/pyexec: Integrate atexit to be run during exit process.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Leech <[email protected]>
  • Loading branch information
andrewleech committed Nov 24, 2024
1 parent ff45348 commit f80c6c7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions shared/runtime/pyexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "py/repl.h"
#include "py/gc.h"
#include "py/frozenmod.h"
#include "py/modatexit.h"
#include "py/mphal.h"
#if MICROPY_HW_ENABLE_USB
#include "irq.h"
Expand Down Expand Up @@ -188,6 +189,11 @@ static int parse_compile_execute(const void *source, mp_parse_input_kind_t input
mp_hal_stdout_tx_strn("\x04", 1);
}

#if MICROPY_PY_ATEXIT
int atexit_code = mp_atexit_execute();
ret = (atexit_code != 0) ? atexit_code : ret;
#endif

#ifdef MICROPY_BOARD_AFTER_PYTHON_EXEC
MICROPY_BOARD_AFTER_PYTHON_EXEC(input_kind, exec_flags, nlr.ret_val, &ret);
#endif
Expand Down

0 comments on commit f80c6c7

Please sign in to comment.