replayer: restore optional max_inflight_sessions for backwards compat
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -59,6 +59,7 @@ class ReplayConfig:
|
|||||||
request_timeout_s: float = 600.0
|
request_timeout_s: float = 600.0
|
||||||
request_limit: int | None = None
|
request_limit: int | None = None
|
||||||
model_name: str = "default"
|
model_name: str = "default"
|
||||||
|
max_inflight_sessions: int | None = None # cap on concurrent sessions; None = unlimited
|
||||||
|
|
||||||
|
|
||||||
def _build_prompt_token_ids(req: TraceRequest) -> list[int]:
|
def _build_prompt_token_ids(req: TraceRequest) -> list[int]:
|
||||||
@@ -215,7 +216,11 @@ async def _run_session(
|
|||||||
earliest_ts: float,
|
earliest_ts: float,
|
||||||
sweep_start: float,
|
sweep_start: float,
|
||||||
sink: IncrementalMetricSink,
|
sink: IncrementalMetricSink,
|
||||||
|
session_sem: asyncio.Semaphore | None = None,
|
||||||
) -> list[RequestMetrics]:
|
) -> list[RequestMetrics]:
|
||||||
|
if session_sem is not None:
|
||||||
|
await session_sem.acquire()
|
||||||
|
try:
|
||||||
for req in state.turns:
|
for req in state.turns:
|
||||||
# Wait until this request's trace timestamp
|
# Wait until this request's trace timestamp
|
||||||
target_wall = (req.timestamp_s - earliest_ts)
|
target_wall = (req.timestamp_s - earliest_ts)
|
||||||
@@ -230,6 +235,9 @@ async def _run_session(
|
|||||||
)
|
)
|
||||||
state.metrics.append(metric)
|
state.metrics.append(metric)
|
||||||
await sink.append(metric)
|
await sink.append(metric)
|
||||||
|
finally:
|
||||||
|
if session_sem is not None:
|
||||||
|
session_sem.release()
|
||||||
|
|
||||||
return state.metrics
|
return state.metrics
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user