INNER CODE UNIT · Python
_drain_detached_control_plane_tasks
Soju06/codex-lb · app/main.py:305
async def _drain_detached_control_plane_tasks(timeout_seconds: float) -> bool:
# Closing admission is synchronous with producer checks on the event loop,
# so no task can appear after the stable drain passes complete.
close_control_plane_task_admission()
loop = asyncio.get_running_loop()
deadline = loop.time() + timeout_seconds
clean_passes = 0
while clean_passes < 2:
remaining = max(0.0, deadline - loop.time())
results = await asyncio.gather(
drain_audit_log_tasks(remaining),
fleet_api.drain_background_refresh_tasks(remaining),
return_exceptions=True,
)
clean_pass = True
for task_kind, result in zip(("audit log", "fleet refresh"), results, strict=True):