Skip to content

Commit f1eda6d

Browse files
andrewleechpi-anl
authored andcommitted
shared/runtime/pyexec: Integrate atexit to be run during exit process.
Signed-off-by: Andrew Leech <[email protected]>
1 parent c11bd0e commit f1eda6d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

shared/runtime/pyexec.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "py/repl.h"
3535
#include "py/gc.h"
3636
#include "py/frozenmod.h"
37+
#include "py/modatexit.h"
3738
#include "py/mphal.h"
3839
#if MICROPY_HW_ENABLE_USB
3940
#include "irq.h"
@@ -188,6 +189,11 @@ static int parse_compile_execute(const void *source, mp_parse_input_kind_t input
188189
mp_hal_stdout_tx_strn("\x04", 1);
189190
}
190191

192+
#if MICROPY_PY_ATEXIT
193+
int atexit_code = mp_atexit_execute();
194+
ret = (atexit_code != 0) ? atexit_code : ret;
195+
#endif
196+
191197
#ifdef MICROPY_BOARD_AFTER_PYTHON_EXEC
192198
MICROPY_BOARD_AFTER_PYTHON_EXEC(input_kind, exec_flags, nlr.ret_val, &ret);
193199
#endif

0 commit comments

Comments
 (0)