Skip to content

Commit

Permalink
@sandergg, @GitHK review: rewrite function as before but with differe…
Browse files Browse the repository at this point in the history
…nt argument name
  • Loading branch information
pcrespov committed Apr 17, 2023
1 parent ebfcede commit 9825da9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions services/director/src/simcore_service_director/producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,17 +534,17 @@ async def _get_service_state(
log.debug("Getting service %s state", service_name)
tasks = await client.tasks.list(filters={"service": service_name})

async def _wait_for_tasks():
async def _wait_for_tasks(target_tasks):
task_started_time = datetime.utcnow()
while (datetime.utcnow() - task_started_time) < timedelta(seconds=20):
tasks = await client.tasks.list(filters={"service": service_name})
target_tasks = await client.tasks.list(filters={"service": service_name})
# only keep the ones with the right service ID (we're being a bit picky maybe)
tasks = [x for x in tasks if x["ServiceID"] == service["ID"]]
if tasks:
target_tasks = [x for x in target_tasks if x["ServiceID"] == service["ID"]]
if target_tasks:
return
await asyncio.sleep(1) # let other events happen too

await _wait_for_tasks()
await _wait_for_tasks(target_tasks=tasks)
if not tasks:
return (ServiceState.FAILED, "getting state timed out")

Expand Down

0 comments on commit 9825da9

Please sign in to comment.