Skip to content

Commit

Permalink
run all ready tasks prior to calling poll in poll_loop.py (#84)
Browse files Browse the repository at this point in the history
This ensures we make as much progress as possible and accumulate as many
`pollable`s as possible prior to calling `poll`.  Previously, we were
accidentally limiting concurrency (and potentially getting stuck in cases where
there were interdepdencencies between tasks) by only running one task per loop.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
  • Loading branch information
dicej committed Apr 11, 2024
1 parent 58c9430 commit fa666b9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bundled/poll_loop.py
Expand Up @@ -125,10 +125,11 @@ def run_until_complete(self, future):
self.running = True
asyncio.events._set_running_loop(self)
while self.running and not future.done():
handle = self.handles[0]
self.handles = self.handles[1:]
if not handle._cancelled:
handle._run()
handles = self.handles
self.handles = []
for handle in handles:
if not handle._cancelled:
handle._run()

if self.wakers:
[pollables, wakers] = list(map(list, zip(*self.wakers)))
Expand Down

0 comments on commit fa666b9

Please sign in to comment.