Skip to content

Commit b2fa1b5

Browse files
committed
ports: Call gc_sweep_all() when doing a soft reset.
This calls finalisers of things like files and sockets to cleanly close them.
1 parent 522ea80 commit b2fa1b5

4 files changed

Lines changed: 9 additions & 0 deletions

File tree

ports/esp32/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ void mp_task(void *pvParameter) {
116116
mp_thread_deinit();
117117
#endif
118118

119+
gc_sweep_all();
120+
119121
mp_hal_stdout_tx_str("PYB: soft reboot\r\n");
120122

121123
// deinitialise peripherals

ports/esp8266/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ STATIC void mp_reset(void) {
8888
}
8989

9090
void soft_reset(void) {
91+
gc_sweep_all();
9192
mp_hal_stdout_tx_str("PYB: soft reboot\r\n");
9293
mp_hal_delay_us(10000); // allow UART to flush output
9394
mp_reset();

ports/stm32/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,5 +756,7 @@ void stm32_main(uint32_t reset_mode) {
756756
pyb_thread_deinit();
757757
#endif
758758

759+
gc_sweep_all();
760+
759761
goto soft_reset;
760762
}

ports/unix/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ MP_NOINLINE int main_(int argc, char **argv) {
647647
}
648648
#endif
649649

650+
#if defined(MICROPY_UNIX_COVERAGE)
651+
gc_sweep_all();
652+
#endif
653+
650654
mp_deinit();
651655

652656
#if MICROPY_ENABLE_GC && !defined(NDEBUG)

0 commit comments

Comments
 (0)