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
Paul Sokolovsky 2014-04-20 00:47:43 +03:00
rodzic b42f8e383b
commit ee495b3807
1 zmienionych plików z 14 dodań i 11 usunięć

Wyświetl plik

@ -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