Skip to content

Commit 0ff198f

Browse files
author
Mateusz
committed
test(usage-cbor): parallelize CBOR capture decode in session fixture
Decode wire capture files with a bounded ThreadPoolExecutor (max 8 workers) so the cbor_stop_chunks fixture keeps full coverage while reducing setup time on multi-file replays. Made-with: Cursor
1 parent 0f5c47e commit 0ff198f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

tests/unit/core/ports/test_usage_chunk_cbor_replay.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from __future__ import annotations
1515

1616
import json
17+
from concurrent.futures import ThreadPoolExecutor, as_completed
1718
from pathlib import Path
1819
from typing import Any, cast
1920

@@ -220,9 +221,15 @@ def cbor_stop_chunks() -> list[dict[str, Any]]:
220221
if not capture_files:
221222
pytest.skip("No CBOR capture files available for replay testing")
222223

224+
# Decode captures in parallel: bounded workers avoid thread overhead on Windows.
225+
max_workers = min(8, max(1, len(capture_files)))
223226
all_chunks: list[dict[str, Any]] = []
224-
for capture_file in capture_files:
225-
all_chunks.extend(_stop_chunks_for_capture_file(capture_file))
227+
with ThreadPoolExecutor(max_workers=max_workers) as pool:
228+
futures = {
229+
pool.submit(_stop_chunks_for_capture_file, p): p for p in capture_files
230+
}
231+
for fut in as_completed(futures):
232+
all_chunks.extend(fut.result())
226233

227234
if not all_chunks:
228235
pytest.skip("No stop chunks with usage found in captures")

0 commit comments

Comments
 (0)