kopia lustrzana https://github.com/micropython/micropython-lib
asyncio: Recover eventloop's ability to work with callbacks.
Actually, coroutine support for call_soon() is a hack, in big asyncio coroutine should be wrapped in Task object.asyncio-segfault
rodzic
78fef25eea
commit
25bcef1b0d
|
@ -46,17 +46,20 @@ class EventLoop:
|
||||||
delay = t - tnow
|
delay = t - tnow
|
||||||
if delay > 0:
|
if delay > 0:
|
||||||
self.wait(delay)
|
self.wait(delay)
|
||||||
delay = 0
|
if callable(cb):
|
||||||
try:
|
cb(*args)
|
||||||
ret = next(cb)
|
else:
|
||||||
# print("ret:", ret)
|
delay = 0
|
||||||
if isinstance(ret, Sleep):
|
try:
|
||||||
delay = ret.args[0]
|
ret = next(cb)
|
||||||
except StopIteration as e:
|
# print("ret:", ret)
|
||||||
print(c, "finished")
|
if isinstance(ret, Sleep):
|
||||||
continue
|
delay = ret.args[0]
|
||||||
#self.q.append(c)
|
except StopIteration as e:
|
||||||
self.call_later(delay, cb, *args)
|
print(c, "finished")
|
||||||
|
continue
|
||||||
|
#self.q.append(c)
|
||||||
|
self.call_later(delay, cb, *args)
|
||||||
|
|
||||||
def run_until_complete(self, coro):
|
def run_until_complete(self, coro):
|
||||||
val = None
|
val = None
|
||||||
|
|
Ładowanie…
Reference in New Issue