Long-live code.py itself.
This commit is contained in:
parent
ec78d3cefd
commit
519287550c
8
lib/utils/pyexec.c
Normal file → Executable file
8
lib/utils/pyexec.c
Normal file → Executable file
@ -33,6 +33,7 @@
|
|||||||
#include "py/runtime.h"
|
#include "py/runtime.h"
|
||||||
#include "py/repl.h"
|
#include "py/repl.h"
|
||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
|
#include "py/gc_long_lived.h"
|
||||||
#include "py/frozenmod.h"
|
#include "py/frozenmod.h"
|
||||||
#include "py/mphal.h"
|
#include "py/mphal.h"
|
||||||
#if defined(USE_DEVICE_MODE)
|
#if defined(USE_DEVICE_MODE)
|
||||||
@ -97,6 +98,13 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the code was loaded from a file its likely to be running for a while so we'll long
|
||||||
|
// live it and collect any garbage before running.
|
||||||
|
if (input_kind == MP_PARSE_FILE_INPUT) {
|
||||||
|
module_fun = make_obj_long_lived(module_fun, 6);
|
||||||
|
gc_collect();
|
||||||
|
}
|
||||||
|
|
||||||
// execute code
|
// execute code
|
||||||
mp_hal_set_interrupt_char(CHAR_CTRL_C); // allow ctrl-C to interrupt us
|
mp_hal_set_interrupt_char(CHAR_CTRL_C); // allow ctrl-C to interrupt us
|
||||||
start = mp_hal_ticks_ms();
|
start = mp_hal_ticks_ms();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user