From 58528e6df2c27bc2cc5cf93c1c92435108ddda53 Mon Sep 17 00:00:00 2001 From: "freddy.li" Date: Thu, 9 Dec 2021 15:20:48 +0800 Subject: [PATCH] Optimize the callback execution logic --- ports/quectel/core/log.py | 2 +- py/scheduler.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/quectel/core/log.py b/ports/quectel/core/log.py index 0aa57d3..bbc004f 100644 --- a/ports/quectel/core/log.py +++ b/ports/quectel/core/log.py @@ -103,7 +103,7 @@ def getLogger(name="root"): def set_output(out): global _stream from machine import UART - if isinstance(out, UART): + if isinstance(out, UART) or out == usys.stderr or out == usys.stdout: _stream = out else: raise Exception("{} must extend UART".format(out)) diff --git a/py/scheduler.c b/py/scheduler.c index a536a3c..429863a 100644 --- a/py/scheduler.c +++ b/py/scheduler.c @@ -191,6 +191,7 @@ bool mp_sched_schedule_ex(c_callback_t *callback, mp_obj_t arg) return mp_sched_schedule(callback->cb, arg); } else { mp_obj_t cb = mp_load_attr(callback->method_self, callback->method_name); + callback->cb = cb;//record a new boundmeth return mp_sched_schedule(cb, arg); } } -- Gitee