Skip to content

Commit 2dacd60

Browse files
committed
py/modthread: Add exit() function.
Simply raises the SystemExit exception.
1 parent 707f98f commit 2dacd60

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

py/modthread.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,17 @@ STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_t *args)
144144
}
145145
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_thread_start_new_thread_obj, 2, 3, mod_thread_start_new_thread);
146146

147+
STATIC mp_obj_t mod_thread_exit(void) {
148+
nlr_raise(mp_obj_new_exception(&mp_type_SystemExit));
149+
}
150+
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_exit_obj, mod_thread_exit);
151+
147152
STATIC const mp_rom_map_elem_t mp_module_thread_globals_table[] = {
148153
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__thread) },
149154
{ MP_ROM_QSTR(MP_QSTR_get_ident), MP_ROM_PTR(&mod_thread_get_ident_obj) },
150155
{ MP_ROM_QSTR(MP_QSTR_stack_size), MP_ROM_PTR(&mod_thread_stack_size_obj) },
151156
{ MP_ROM_QSTR(MP_QSTR_start_new_thread), MP_ROM_PTR(&mod_thread_start_new_thread_obj) },
157+
{ MP_ROM_QSTR(MP_QSTR_exit), MP_ROM_PTR(&mod_thread_exit_obj) },
152158
};
153159

154160
STATIC MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_table);

0 commit comments

Comments
 (0)