uasyncio.core: Log only if __debug__==True (i.e. no optimization).

pull/11/head
Paul Sokolovsky 2014-10-26 00:20:24 +03:00
rodzic b684b448d1
commit cbaf0d3b57
1 zmienionych plików z 10 dodań i 5 usunięć

Wyświetl plik

@ -24,6 +24,7 @@ class EventLoop:
def call_at(self, time, callback, *args):
# Including self.cnt is a workaround per heapq docs
if __debug__:
log.debug("Scheduling %s", (time, self.cnt, callback, args))
heapq.heappush(self.q, (time, self.cnt, callback, args))
# print(self.q)
@ -39,6 +40,7 @@ class EventLoop:
while True:
if self.q:
t, cnt, cb, args = heapq.heappop(self.q)
if __debug__:
log.debug("Next coroutine to run: %s", (t, cnt, cb, args))
# __main__.mem_info()
tnow = self.time()
@ -56,8 +58,10 @@ class EventLoop:
try:
if args == ():
args = (None,)
if __debug__:
log.debug("Coroutine %s send args: %s", cb, args)
ret = cb.send(*args)
if __debug__:
log.debug("Coroutine %s yield result: %s", cb, ret)
if isinstance(ret, SysCall):
arg = ret.args[0]
@ -85,6 +89,7 @@ class EventLoop:
else:
assert False, "Unsupported coroutine yield value: %r (of type %r)" % (ret, type(ret))
except StopIteration as e:
if __debug__:
log.debug("Coroutine finished: %s", cb)
continue
self.call_later(delay, cb, *args)