uasyncio.core: Make I/O scheduling fair wrt to computational scheduling.

If there is a coroutine to run immediately (with wait delay <= 0),
uasyncio.core never called .wait() method, which is required to
process I/O events (and schedule coroutines waiting for them). So
now, call .wait(0) even if there's a coroutine to run immediately.
pull/183/merge
Paul Sokolovsky 2017-08-20 17:04:31 +03:00
rodzic 65605e3de8
commit eef054d98a
1 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -59,9 +59,12 @@ class EventLoop:
t = self.q.peektime()
tnow = self.time()
delay = time.ticks_diff(t, tnow)
if delay <= 0:
break
if delay < 0:
delay = 0
# Always call wait(), to give a chance to I/O scheduling
self.wait(delay)
if delay == 0:
break
self.q.pop(cur_task)
t = cur_task[0]