log.info("Syncing state with AWS")
# Sync all builders
- await asyncio.gather(*(builder.sync() for builder in self))
+ async with asyncio.TaskGroup() as tasks:
+ for builder in self:
+ tasks.create_task(
+ builder.sync(),
+ )
async def autoscale(self, wait=False):
"""
builder for builder in builders if not queue[builder] and builder.is_idle()
]
- # Start all builders that have been allocated at least one job
- await asyncio.gather(
- *(builder.start(wait=wait) for builder in builders_to_be_launched),
- )
+ async with asyncio.TaskGroup() as tasks:
+ # Start all builders that have been allocated at least one job
+ for builder in builders_to_be_launched:
+ tasks.create_task(
+ builder.start(wait=wait),
+ )
- # Shutdown the rest
- await asyncio.gather(
- *(builder.stop(wait=wait) for builder in builders_to_be_shut_down),
- )
+ # Shutdown the rest
+ for builder in builders_to_be_shut_down:
+ tasks.create_task(
+ builder.stop(wait=wait),
+ )
# Stats
return
# Send the stats to all connections
- await asyncio.gather(
- *(c.submit_stats(stats) for c in connections),
- )
+ async with asyncio.TaskGroup() as tasks:
+ for c in connections:
+ tasks.create_task(
+ c.submit_stats(stats),
+ )
class Builder(base.DataObject):