asyncio: Make run_forever() actually run forever.

asyncio-segfault
Paul Sokolovsky 2014-04-20 05:58:12 +03:00
rodzic 25bcef1b0d
commit e2403bde0a
1 zmienionych plików z 11 dodań i 7 usunięć

Wyświetl plik

@ -39,13 +39,17 @@ class EventLoop:
time.sleep(delay)
def run_forever(self):
while self.q:
# t, cnt, cb, args = self.q.pop(0)
t, cnt, cb, args = heapq.heappop(self.q)
tnow = self.time()
delay = t - tnow
if delay > 0:
self.wait(delay)
while True:
if self.q:
t, cnt, cb, args = heapq.heappop(self.q)
tnow = self.time()
delay = t - tnow
if delay > 0:
self.wait(delay)
else:
self.wait(-1)
# Assuming IO completion scheduled some tasks
continue
if callable(cb):
cb(*args)
else: