uasyncio.core: Store currently executed task as an attribute of event loop.

Currently executed task is a top-level coroutine scheduled in the event
loop (note that sub-coroutines aren't scheduled in the event loop and
are executed implicitly by yield from/await, driven by top-level coro).
pull/234/merge
Paul Sokolovsky 2017-12-03 00:22:17 +02:00
rodzic d87573b113
commit afa6192501
1 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -19,6 +19,10 @@ class EventLoop:
def __init__(self, len=42):
self.q = utimeq.utimeq(len)
# Current task being run. Task is a top-level coroutine scheduled
# in the event loop (sub-coroutines executed transparently by
# yield from/await, event loop "doesn't see" them).
self.cur_task = None
def time(self):
return time.ticks_ms()
@ -72,6 +76,7 @@ class EventLoop:
args = cur_task[2]
if __debug__ and DEBUG:
log.debug("Next coroutine to run: %s", (t, cb, args))
self.cur_task = cb
# __main__.mem_info()
else:
self.wait(-1)