Skip to content

Commit

Permalink
Fixed #516.
Browse files Browse the repository at this point in the history
The HTTP distributor was calling asyncio.wait with an empty iterable,
and this was causing an exception. We now avoid that condition.
  • Loading branch information
abingham committed Jul 29, 2021
1 parent dde3bc9 commit 2be55c2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/cosmic_ray/distribution/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async def handle_completed_task(task):
for work_item in pending_work:
# Wait for an available URL
while not urls:
assert fetchers.keys()
done, pending = await asyncio.wait(fetchers.keys(), return_when=asyncio.FIRST_COMPLETED)
for task in done:
await handle_completed_task(task)
Expand All @@ -84,9 +85,10 @@ async def handle_completed_task(task):
fetchers[fetcher] = url, work_item.job_id

# Drain the remaining work
done, pending = await asyncio.wait(fetchers.keys(), return_when=asyncio.ALL_COMPLETED)
for task in done:
await handle_completed_task(task)
if fetchers.keys():
done, pending = await asyncio.wait(fetchers.keys(), return_when=asyncio.ALL_COMPLETED)
for task in done:
await handle_completed_task(task)


async def send_request(url, work_item: WorkItem, test_command, timeout):
Expand Down

0 comments on commit 2be55c2

Please sign in to comment.