File tree Expand file tree Collapse file tree 11 files changed +38
-4
lines changed Expand file tree Collapse file tree 11 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,10 @@ void mp_task(void *pvParameter) {
182182 mp_thread_deinit ();
183183 #endif
184184
185+ #if MICROPY_PY_SYS_ATEXIT
186+ mp_sys_atexit_execute ();
187+ #endif
188+
185189 gc_sweep_all ();
186190
187191 // Free any native code pointers that point to iRAM.
Original file line number Diff line number Diff line change @@ -88,6 +88,9 @@ static void mp_reset(void) {
8888}
8989
9090void soft_reset (void ) {
91+ #if MICROPY_PY_SYS_ATEXIT
92+ mp_sys_atexit_execute ();
93+ #endif
9194 gc_sweep_all ();
9295 mp_hal_stdout_tx_str ("MPY: soft reboot\r\n" );
9396 mp_hal_delay_us (10000 ); // allow UART to flush output
Original file line number Diff line number Diff line change @@ -159,6 +159,9 @@ int main(void) {
159159 machine_uart_deinit_all ();
160160 machine_pwm_deinit_all ();
161161 soft_timer_deinit ();
162+ #if MICROPY_PY_SYS_ATEXIT
163+ mp_sys_atexit_execute ();
164+ #endif
162165 gc_sweep_all ();
163166 mp_deinit ();
164167 }
Original file line number Diff line number Diff line change @@ -292,6 +292,11 @@ void NORETURN _start(void) {
292292 pwm_deinit_all ();
293293 #endif
294294
295+ #if MICROPY_PY_SYS_ATEXIT
296+ mp_sys_atexit_execute ();
297+ #endif
298+
299+ gc_sweep_all ();
295300 mp_deinit ();
296301
297302 printf ("MPY: soft reboot\n" );
Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ int main(int argc, char **argv) {
6060
6161 mp_printf (& mp_plat_print , "MPY: soft reboot\n" );
6262
63+ #if MICROPY_PY_SYS_ATEXIT
64+ mp_sys_atexit_execute ();
65+ #endif
6366 gc_sweep_all ();
6467 mp_deinit ();
6568 }
Original file line number Diff line number Diff line change @@ -435,6 +435,10 @@ int main(void) {
435435 pyb_thread_deinit ();
436436 #endif
437437
438+ #if MICROPY_PY_SYS_ATEXIT
439+ mp_sys_atexit_execute ();
440+ #endif
441+
438442 MICROPY_BOARD_END_SOFT_RESET (& state );
439443
440444 gc_sweep_all ();
Original file line number Diff line number Diff line change @@ -241,6 +241,9 @@ int main(int argc, char **argv) {
241241 #if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
242242 mp_usbd_deinit ();
243243 #endif
244+ #if MICROPY_PY_SYS_ATEXIT
245+ mp_sys_atexit_execute ();
246+ #endif
244247
245248 // Hook for resetting anything right at the end of a soft reset command.
246249 MICROPY_BOARD_END_SOFT_RESET ();
Original file line number Diff line number Diff line change @@ -98,6 +98,9 @@ void samd_main(void) {
9898 #if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
9999 mp_usbd_deinit ();
100100 #endif
101+ #if MICROPY_PY_SYS_ATEXIT
102+ mp_sys_atexit_execute ();
103+ #endif
101104 gc_sweep_all ();
102105 #if MICROPY_PY_MACHINE_I2C || MICROPY_PY_MACHINE_SPI || MICROPY_PY_MACHINE_UART
103106 sercom_deinit_all ();
Original file line number Diff line number Diff line change @@ -698,6 +698,10 @@ void stm32_main(uint32_t reset_mode) {
698698 MP_STATE_PORT (pyb_stdio_uart ) = NULL ;
699699 #endif
700700
701+ #if MICROPY_PY_SYS_ATEXIT
702+ mp_sys_atexit_execute ();
703+ #endif
704+
701705 MICROPY_BOARD_END_SOFT_RESET (& state );
702706
703707 gc_sweep_all ();
Original file line number Diff line number Diff line change 4343#include "py/builtin.h"
4444#include "py/repl.h"
4545#include "py/gc.h"
46+ #include "py/objmodule.h"
4647#include "py/objstr.h"
4748#include "py/cstack.h"
4849#include "py/mphal.h"
@@ -753,10 +754,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
753754 #endif
754755
755756 #if MICROPY_PY_SYS_ATEXIT
756- // Beware, the sys.settrace callback should be disabled before running sys.atexit.
757- if (mp_obj_is_callable (MP_STATE_VM (sys_exitfunc ))) {
758- mp_call_function_0 (MP_STATE_VM (sys_exitfunc ));
759- }
757+ mp_sys_atexit_execute ();
760758 #endif
761759
762760 #if MICROPY_PY_MICROPYTHON_MEM_INFO
You can’t perform that action at this time.
0 commit comments