summaryrefslogtreecommitdiff
path: root/py/modthread.c
diff options
context:
space:
mode:
authorDavid Lechner <david@pybricks.com>2021-05-10 21:53:22 -0500
committerDamien George <damien@micropython.org>2021-06-19 09:43:44 +1000
commitca920f72184c50f61002aa9d5cd01555b1e28b7b (patch)
treea46b6cb9c91a275015b351443d1cb1181d8c5d14 /py/modthread.c
parent7c51cb2307eaca1a1ccc071e0bb5eb4a5f734610 (diff)
py/mpstate: Make exceptions thread-local.
This moves mp_pending_exception from mp_state_vm_t to mp_state_thread_t. This allows exceptions to be scheduled on a specific thread. Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'py/modthread.c')
-rw-r--r--py/modthread.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/py/modthread.c b/py/modthread.c
index 64fbb3f19..29b765493 100644
--- a/py/modthread.c
+++ b/py/modthread.c
@@ -174,6 +174,8 @@ STATIC void *thread_entry(void *args_in) {
// The GC starts off unlocked on this thread.
ts.gc_lock_depth = 0;
+ ts.mp_pending_exception = MP_OBJ_NULL;
+
// set locals and globals from the calling context
mp_locals_set(args->dict_locals);
mp_globals_set(args->dict_globals);
@@ -184,7 +186,6 @@ STATIC void *thread_entry(void *args_in) {
mp_thread_start();
// TODO set more thread-specific state here:
- // mp_pending_exception? (root pointer)
// cur_exception (root pointer)
DEBUG_printf("[thread] start ts=%p args=%p stack=%p\n", &ts, &args, MP_STATE_THREAD(stack_top));