kopia lustrzana https://github.com/micropython/micropython-lib
uasyncio.core: Log only if __debug__==True (i.e. no optimization).
rodzic
b684b448d1
commit
cbaf0d3b57
|
@ -24,6 +24,7 @@ class EventLoop:
|
||||||
|
|
||||||
def call_at(self, time, callback, *args):
|
def call_at(self, time, callback, *args):
|
||||||
# Including self.cnt is a workaround per heapq docs
|
# Including self.cnt is a workaround per heapq docs
|
||||||
|
if __debug__:
|
||||||
log.debug("Scheduling %s", (time, self.cnt, callback, args))
|
log.debug("Scheduling %s", (time, self.cnt, callback, args))
|
||||||
heapq.heappush(self.q, (time, self.cnt, callback, args))
|
heapq.heappush(self.q, (time, self.cnt, callback, args))
|
||||||
# print(self.q)
|
# print(self.q)
|
||||||
|
@ -39,6 +40,7 @@ class EventLoop:
|
||||||
while True:
|
while True:
|
||||||
if self.q:
|
if self.q:
|
||||||
t, cnt, cb, args = heapq.heappop(self.q)
|
t, cnt, cb, args = heapq.heappop(self.q)
|
||||||
|
if __debug__:
|
||||||
log.debug("Next coroutine to run: %s", (t, cnt, cb, args))
|
log.debug("Next coroutine to run: %s", (t, cnt, cb, args))
|
||||||
# __main__.mem_info()
|
# __main__.mem_info()
|
||||||
tnow = self.time()
|
tnow = self.time()
|
||||||
|
@ -56,8 +58,10 @@ class EventLoop:
|
||||||
try:
|
try:
|
||||||
if args == ():
|
if args == ():
|
||||||
args = (None,)
|
args = (None,)
|
||||||
|
if __debug__:
|
||||||
log.debug("Coroutine %s send args: %s", cb, args)
|
log.debug("Coroutine %s send args: %s", cb, args)
|
||||||
ret = cb.send(*args)
|
ret = cb.send(*args)
|
||||||
|
if __debug__:
|
||||||
log.debug("Coroutine %s yield result: %s", cb, ret)
|
log.debug("Coroutine %s yield result: %s", cb, ret)
|
||||||
if isinstance(ret, SysCall):
|
if isinstance(ret, SysCall):
|
||||||
arg = ret.args[0]
|
arg = ret.args[0]
|
||||||
|
@ -85,6 +89,7 @@ class EventLoop:
|
||||||
else:
|
else:
|
||||||
assert False, "Unsupported coroutine yield value: %r (of type %r)" % (ret, type(ret))
|
assert False, "Unsupported coroutine yield value: %r (of type %r)" % (ret, type(ret))
|
||||||
except StopIteration as e:
|
except StopIteration as e:
|
||||||
|
if __debug__:
|
||||||
log.debug("Coroutine finished: %s", cb)
|
log.debug("Coroutine finished: %s", cb)
|
||||||
continue
|
continue
|
||||||
self.call_later(delay, cb, *args)
|
self.call_later(delay, cb, *args)
|
||||||
|
|
Ładowanie…
Reference in New Issue