From 4300dc025a37f0242910ce443bd7345f21078275 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 25 Apr 2026 10:50:16 +0000 Subject: [PATCH] fix: use unique env-file path in DaytonaPtyProcess to avoid race conditions DaytonaPtyProcess.start() used a hardcoded /tmp/.benchflow_env path, meaning concurrent instances on the same host would overwrite each other's env file. Use uuid.uuid4().hex[:16] suffix to match the pattern already used in DaytonaProcess.start(). Also removes redundant local 'import uuid' since it's already imported at module level. Flagged by Devin Review on PR #198. Co-Authored-By: Xiangyi Li --- src/benchflow/process.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/benchflow/process.py b/src/benchflow/process.py index b9d2c21..80c380b 100644 --- a/src/benchflow/process.py +++ b/src/benchflow/process.py @@ -444,7 +444,6 @@ async def start( env: dict[str, str] | None = None, cwd: str | None = None, ) -> None: - import uuid session_id = f"acp-{uuid.uuid4().hex[:8]}" pty_env = {} if self._compose_cmd_prefix: @@ -469,10 +468,11 @@ async def start( # matching the approach in DaytonaProcess.start(). env_file_cmd = "" if env: + env_file_path = f"/tmp/.benchflow_env_{uuid.uuid4().hex[:16]}" env_lines = "\n".join(f"export {k}={shlex.quote(v)}" for k, v in env.items()) env_file_cmd = ( - f"cat > /tmp/.benchflow_env <<'__EOF__'\n{env_lines}\n__EOF__\n" - f". /tmp/.benchflow_env && rm -f /tmp/.benchflow_env && " + f"cat > {env_file_path} <<'__EOF__'\n{env_lines}\n__EOF__\n" + f". {env_file_path} && rm -f {env_file_path} && " ) exec_parts.extend(["main", "bash", "-lc", f"{env_file_cmd}{command}"]) exec_cmd = shlex.join(exec_parts)