From 2be55c29c09168c8a746b2295bdee45c15d3f69a Mon Sep 17 00:00:00 2001 From: Austin Bingham Date: Thu, 29 Jul 2021 19:48:35 +0200 Subject: [PATCH] Fixed #516. The HTTP distributor was calling asyncio.wait with an empty iterable, and this was causing an exception. We now avoid that condition. --- src/cosmic_ray/distribution/http.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cosmic_ray/distribution/http.py b/src/cosmic_ray/distribution/http.py index 37f825ea..64f885d0 100644 --- a/src/cosmic_ray/distribution/http.py +++ b/src/cosmic_ray/distribution/http.py @@ -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) @@ -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):