mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-15 00:51:59 +00:00
口径比对的 drain(测试用)只等还没做完的任务,做完还留在登记里的顺手去掉
为什么:并行跑全量测试时偶发过 drain 原地空转(faulthandler 抓到主线程一直在 drain 里,每轮 gather 都立刻返回),四次全量里挂了两次。这一波起整题等价的探索运行比完会接着自动出具,后台任务的进出更密。改成只 gather 没做完的、把做完的从登记里去掉之后,连跑两次全量都没再出现。drain 只给测试用,服务里不调它;没能在单进程里复现出根因,照实记进遗留。
This commit is contained in:
@@ -596,9 +596,17 @@ def _mine() -> list[asyncio.Task[Any]]:
|
||||
|
||||
|
||||
async def drain() -> None:
|
||||
"""等这个事件循环里的后台比对都做完(测试用)。"""
|
||||
while tasks := _mine():
|
||||
await asyncio.gather(*tasks, return_exceptions=True)
|
||||
"""等这个事件循环里的后台比对都做完(测试用)。只等还没做完的:已经做完、还留在登记里的(完成回调还没来得及跑)顺手
|
||||
去掉——不然对着做完的任务反复 gather,事件循环原地空转(并行跑全量测试时偶发过)。"""
|
||||
while True:
|
||||
tasks = _mine()
|
||||
for task in tasks:
|
||||
if task.done():
|
||||
_background.discard(task)
|
||||
live = [task for task in tasks if not task.done()]
|
||||
if not live:
|
||||
return
|
||||
await asyncio.gather(*live, return_exceptions=True)
|
||||
|
||||
|
||||
async def shutdown() -> None:
|
||||
|
||||
Reference in New Issue
Block a user