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.pull/11/head
rodzic
b42f8e383b
commit
ee495b3807
|
@ -46,17 +46,20 @@ class EventLoop:
|
|||
delay = t - tnow
|
||||
if delay > 0:
|
||||
self.wait(delay)
|
||||
delay = 0
|
||||
try:
|
||||
ret = next(cb)
|
||||
# print("ret:", ret)
|
||||
if isinstance(ret, Sleep):
|
||||
delay = ret.args[0]
|
||||
except StopIteration as e:
|
||||
print(c, "finished")
|
||||
continue
|
||||
#self.q.append(c)
|
||||
self.call_later(delay, cb, *args)
|
||||
if callable(cb):
|
||||
cb(*args)
|
||||
else:
|
||||
delay = 0
|
||||
try:
|
||||
ret = next(cb)
|
||||
# print("ret:", ret)
|
||||
if isinstance(ret, Sleep):
|
||||
delay = ret.args[0]
|
||||
except StopIteration as e:
|
||||
print(c, "finished")
|
||||
continue
|
||||
#self.q.append(c)
|
||||
self.call_later(delay, cb, *args)
|
||||
|
||||
def run_until_complete(self, coro):
|
||||
val = None
|
||||
|
|
Ładowanie…
Reference in New Issue