#3060·agentscope

[错误]: Bash 超时或停止不会停止本地后端的命令

作者: zaher-m创建于 2026年9月30日更新于 2026年9月30日
标签Bugtriage/confirmed

async def run(command: str, timeout_ms: int) -> None: start = time.monotonic() async for _ in await Bash()(command=command, timeout=timeout_ms): pass took = time.monotonic() - start print(f"{command!r}, timeout {timeout_ms} ms: returned after {took:.1f} s")

async def stop_while_running() -> None: mark = os.path.join(tempfile.mkdtemp(), "mark") task = asyncio.create_task(run(f"sleep 1; touch {mark}", 10_000)) await asyncio.sleep(0.3) task.cancel() try: await task except asyncio.CancelledError: pass await asyncio.sleep(2) print("the command kept running after the stop:", os.path.exists(mark))

async def main() -> None: await run("sleep 3", 1000)

内容来源: agentscope-ai/agentscope