File tree Expand file tree Collapse file tree 11 files changed +48
-4
lines changed Expand file tree Collapse file tree 11 files changed +48
-4
lines changed Original file line number Diff line number Diff line change 49
49
#include "py/repl.h"
50
50
#include "py/gc.h"
51
51
#include "py/mphal.h"
52
+ #include "py/objmodule.h"
52
53
#include "shared/readline/readline.h"
53
54
#include "shared/runtime/pyexec.h"
54
55
#include "shared/timeutils/timeutils.h"
@@ -182,6 +183,10 @@ void mp_task(void *pvParameter) {
182
183
mp_thread_deinit ();
183
184
#endif
184
185
186
+ #if MICROPY_PY_SYS_ATEXIT
187
+ mp_sys_atexit_execute ();
188
+ #endif
189
+
185
190
gc_sweep_all ();
186
191
187
192
// Free any native code pointers that point to iRAM.
Original file line number Diff line number Diff line change 35
35
#include "py/mperrno.h"
36
36
#include "py/mphal.h"
37
37
#include "py/gc.h"
38
+ #include "py/objmodule.h"
38
39
39
40
#include "extmod/misc.h"
40
41
#include "extmod/modmachine.h"
@@ -88,6 +89,9 @@ static void mp_reset(void) {
88
89
}
89
90
90
91
void soft_reset (void ) {
92
+ #if MICROPY_PY_SYS_ATEXIT
93
+ mp_sys_atexit_execute ();
94
+ #endif
91
95
gc_sweep_all ();
92
96
mp_hal_stdout_tx_str ("MPY: soft reboot\r\n" );
93
97
mp_hal_delay_us (10000 ); // allow UART to flush output
Original file line number Diff line number Diff line change 30
30
#include "py/gc.h"
31
31
#include "py/mperrno.h"
32
32
#include "py/stackctrl.h"
33
+ #include "py/objmodule.h"
33
34
#include "shared/readline/readline.h"
34
35
#include "shared/runtime/gchelper.h"
35
36
#include "shared/runtime/pyexec.h"
@@ -159,6 +160,9 @@ int main(void) {
159
160
machine_uart_deinit_all ();
160
161
machine_pwm_deinit_all ();
161
162
soft_timer_deinit ();
163
+ #if MICROPY_PY_SYS_ATEXIT
164
+ mp_sys_atexit_execute ();
165
+ #endif
162
166
gc_sweep_all ();
163
167
mp_deinit ();
164
168
}
Original file line number Diff line number Diff line change 35
35
#include "py/lexer.h"
36
36
#include "py/parse.h"
37
37
#include "py/obj.h"
38
+ #include "py/objmodule.h"
38
39
#include "py/runtime.h"
39
40
#include "py/stackctrl.h"
40
41
#include "py/gc.h"
@@ -292,6 +293,11 @@ void NORETURN _start(void) {
292
293
pwm_deinit_all ();
293
294
#endif
294
295
296
+ #if MICROPY_PY_SYS_ATEXIT
297
+ mp_sys_atexit_execute ();
298
+ #endif
299
+
300
+ gc_sweep_all ();
295
301
mp_deinit ();
296
302
297
303
printf ("MPY: soft reboot\n" );
Original file line number Diff line number Diff line change 31
31
#include "py/stackctrl.h"
32
32
#include "py/gc.h"
33
33
#include "py/mperrno.h"
34
+ #include "py/objmodule.h"
34
35
#include "shared/runtime/gchelper.h"
35
36
#include "shared/runtime/pyexec.h"
36
37
@@ -60,6 +61,9 @@ int main(int argc, char **argv) {
60
61
61
62
mp_printf (& mp_plat_print , "MPY: soft reboot\n" );
62
63
64
+ #if MICROPY_PY_SYS_ATEXIT
65
+ mp_sys_atexit_execute ();
66
+ #endif
63
67
gc_sweep_all ();
64
68
mp_deinit ();
65
69
}
Original file line number Diff line number Diff line change 33
33
#include "py/gc.h"
34
34
#include "py/mperrno.h"
35
35
#include "py/mphal.h"
36
+ #include "py/objmodule.h"
36
37
#include "shared/readline/readline.h"
37
38
#include "shared/runtime/pyexec.h"
38
39
#include "shared/runtime/softtimer.h"
@@ -435,6 +436,10 @@ int main(void) {
435
436
pyb_thread_deinit ();
436
437
#endif
437
438
439
+ #if MICROPY_PY_SYS_ATEXIT
440
+ mp_sys_atexit_execute ();
441
+ #endif
442
+
438
443
MICROPY_BOARD_END_SOFT_RESET (& state );
439
444
440
445
gc_sweep_all ();
Original file line number Diff line number Diff line change 32
32
#include "py/gc.h"
33
33
#include "py/mperrno.h"
34
34
#include "py/mphal.h"
35
+ #include "py/objmodule.h"
35
36
#include "extmod/modbluetooth.h"
36
37
#include "extmod/modnetwork.h"
37
38
#include "shared/readline/readline.h"
@@ -241,6 +242,9 @@ int main(int argc, char **argv) {
241
242
#if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
242
243
mp_usbd_deinit ();
243
244
#endif
245
+ #if MICROPY_PY_SYS_ATEXIT
246
+ mp_sys_atexit_execute ();
247
+ #endif
244
248
245
249
// Hook for resetting anything right at the end of a soft reset command.
246
250
MICROPY_BOARD_END_SOFT_RESET ();
Original file line number Diff line number Diff line change 29
29
#include "py/gc.h"
30
30
#include "py/mperrno.h"
31
31
#include "py/stackctrl.h"
32
+ #include "py/objmodule.h"
32
33
#include "shared/readline/readline.h"
33
34
#include "shared/runtime/gchelper.h"
34
35
#include "shared/runtime/pyexec.h"
@@ -98,6 +99,9 @@ void samd_main(void) {
98
99
#if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
99
100
mp_usbd_deinit ();
100
101
#endif
102
+ #if MICROPY_PY_SYS_ATEXIT
103
+ mp_sys_atexit_execute ();
104
+ #endif
101
105
gc_sweep_all ();
102
106
#if MICROPY_PY_MACHINE_I2C || MICROPY_PY_MACHINE_SPI || MICROPY_PY_MACHINE_UART
103
107
sercom_deinit_all ();
Original file line number Diff line number Diff line change 32
32
#include "py/gc.h"
33
33
#include "py/mperrno.h"
34
34
#include "py/mphal.h"
35
+ #include "py/objmodule.h"
35
36
#include "shared/readline/readline.h"
36
37
#include "shared/runtime/pyexec.h"
37
38
#include "shared/runtime/softtimer.h"
@@ -698,6 +699,10 @@ void stm32_main(uint32_t reset_mode) {
698
699
MP_STATE_PORT (pyb_stdio_uart ) = NULL ;
699
700
#endif
700
701
702
+ #if MICROPY_PY_SYS_ATEXIT
703
+ mp_sys_atexit_execute ();
704
+ #endif
705
+
701
706
MICROPY_BOARD_END_SOFT_RESET (& state );
702
707
703
708
gc_sweep_all ();
Original file line number Diff line number Diff line change 43
43
#include "py/builtin.h"
44
44
#include "py/repl.h"
45
45
#include "py/gc.h"
46
+ #include "py/objmodule.h"
46
47
#include "py/objstr.h"
47
48
#include "py/cstack.h"
48
49
#include "py/mphal.h"
@@ -753,10 +754,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
753
754
#endif
754
755
755
756
#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 ();
760
758
#endif
761
759
762
760
#if MICROPY_PY_MICROPYTHON_MEM_INFO
You can’t perform that action at this time.
0 commit comments