Skip to content

Commit edc5b27

Browse files
committed
fix: use monotonic codex-subagent timers
1 parent 71e95e2 commit edc5b27

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

codex-subagent/scripts/run_batch.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def run_task(
309309
if sandbox == "workspace-write":
310310
pre_files = _git_changed_files(resolved_cwd)
311311

312-
t0 = time.time()
312+
t0 = time.monotonic()
313313
pid_path = os.path.join(task_dir, "pid")
314314
stdout_path = os.path.join(task_dir, "stdout.txt")
315315
stderr_path = os.path.join(task_dir, "stderr.txt")
@@ -370,13 +370,13 @@ def _read_stderr() -> None:
370370
stdout_thread.join()
371371
stderr_thread.join()
372372

373-
elapsed = time.time() - t0
373+
elapsed = time.monotonic() - t0
374374
if thread_errors:
375375
runner_error = thread_errors[0]
376376
else:
377377
stdout_size, stdout_summary_bytes = stdout_thread_result["value"]
378378
except Exception as exc: # noqa: BLE001
379-
elapsed = time.time() - t0
379+
elapsed = time.monotonic() - t0
380380
runner_error = exc
381381
if proc is not None and proc.poll() is None:
382382
proc.kill()
@@ -484,7 +484,7 @@ def main() -> None:
484484

485485
# Dispatch tasks in parallel.
486486
results: list[dict[str, Any]] = []
487-
overall_t0 = time.time()
487+
overall_t0 = time.monotonic()
488488
max_workers = max(1, min(len(tasks), args.max_concurrency))
489489

490490
with ThreadPoolExecutor(max_workers=max_workers) as pool:
@@ -499,7 +499,7 @@ def main() -> None:
499499
except Exception as exc: # noqa: BLE001
500500
results.append(_build_failure_result(task, exc))
501501

502-
total_elapsed = time.time() - overall_t0
502+
total_elapsed = time.monotonic() - overall_t0
503503

504504
# Sort results by original task order.
505505
id_order = {t["id"]: i for i, t in enumerate(tasks)}

0 commit comments

Comments
 (0)