summaryrefslogtreecommitdiffstatshomepage
path: root/py/scheduler.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-04-28 10:52:19 +1000
committerDamien George <damien@micropython.org>2021-04-30 15:13:43 +1000
commit7cbf826a9575e18ce1b7fe11b0f0997509153260 (patch)
tree86cb6ddc61febdf3fbae964fd10eb9ecc62a52fa /py/scheduler.c
parent7e549b6718e80136b03074765f1d4add209a21a5 (diff)
downloadmicropython-7cbf826a9575e18ce1b7fe11b0f0997509153260.tar.gz
micropython-7cbf826a9575e18ce1b7fe11b0f0997509153260.zip
py/scheduler: Add mp_sched_exception() to schedule a pending exception.
This helper is added to properly set a pending exception, to mirror mp_sched_schedule(), which schedules a function. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/scheduler.c')
-rw-r--r--py/scheduler.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/py/scheduler.c b/py/scheduler.c
index 6b138a631b..f37f8c3f86 100644
--- a/py/scheduler.c
+++ b/py/scheduler.c
@@ -28,17 +28,21 @@
#include "py/runtime.h"
-#if MICROPY_KBD_EXCEPTION
-// This function may be called asynchronously at any time so only do the bare minimum.
-void MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(mp_keyboard_interrupt)(void) {
- MP_STATE_VM(mp_kbd_exception).traceback_data = NULL;
- MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
+void mp_sched_exception(mp_obj_t exc) {
+ MP_STATE_VM(mp_pending_exception) = exc;
#if MICROPY_ENABLE_SCHEDULER
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
}
#endif
}
+
+#if MICROPY_KBD_EXCEPTION
+// This function may be called asynchronously at any time so only do the bare minimum.
+void MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(mp_keyboard_interrupt)(void) {
+ MP_STATE_VM(mp_kbd_exception).traceback_data = NULL;
+ mp_sched_exception(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
+}
#endif
#if MICROPY_ENABLE_SCHEDULER