Skip to content

Conversation

@yaugenst-flex
Copy link
Collaborator

@yaugenst-flex yaugenst-flex commented Jan 7, 2026

Fixes intermittent h5py file-locking errors under xdist when multiple test_async cases call run_async with the default path_dir=".", causing concurrent writes to ./batch.hdf5.

Changes:

  • Pass path_dir=str(tmp_path) to run_async in async web tests so each worker writes to an isolated directory.

Checks:

  • poetry run pytest -q --no-cov -W ignore tests/test_web/ --maxfail=1

Note

Addresses xdist flakiness by isolating async test artifacts per worker.

  • Update async tests in test_webapi*.py to pass path_dir=str(tmp_path) to run_async
  • Add tmp_path fixture to corresponding test_async signatures

Written by Cursor Bugbot for commit f1a54c1. This will update automatically on new commits. Configure here.

Greptile Summary

This PR fixes flaky xdist failures in async web tests by isolating test artifacts per worker. The issue occurred when multiple test workers concurrently called run_async with the default path_dir=".", causing concurrent writes to the same ./batch.hdf5 file and h5py file-locking errors.

Changes: All five async test functions (test_async in test_webapi.py, test_webapi_eme.py, test_webapi_heat.py, test_webapi_mode.py, and test_webapi_mode_sim.py) now:

  • Accept the tmp_path pytest fixture parameter
  • Pass path_dir=str(tmp_path) to run_async() calls

This ensures each test worker writes to its own isolated temporary directory, preventing file contention and flaky failures under parallel test execution.

Confidence Score: 5/5

  • This PR is safe to merge with no concerns - it only adjusts test isolation to fix xdist flakiness.
  • Score reflects minimal, targeted changes that directly address the root cause of xdist flakiness. All five test files are updated consistently and correctly. The changes use the standard pytest tmp_path fixture as recommended by the custom instruction rule 6efa8f43. No logic changes, no API changes, and no side effects to existing functionality.
  • No files require special attention

Important Files Changed

Filename Overview
tests/test_web/test_webapi.py Added tmp_path fixture to test_async function signature and passed path_dir=str(tmp_path) to run_async() call to isolate async test artifacts to temporary directory per worker.
tests/test_web/test_webapi_eme.py Added tmp_path fixture to test_async function signature and passed path_dir=str(tmp_path) to run_async() call to isolate async test artifacts to temporary directory per worker.
tests/test_web/test_webapi_heat.py Added tmp_path fixture to test_async function signature and passed path_dir=str(tmp_path) to run_async() call to isolate async test artifacts to temporary directory per worker.
tests/test_web/test_webapi_mode.py Added tmp_path fixture to test_async function signature and passed path_dir=str(tmp_path) to run_async() call to isolate async test artifacts to temporary directory per worker.
tests/test_web/test_webapi_mode_sim.py Added tmp_path fixture to test_async function signature and passed path_dir=str(tmp_path) to run_async() call to isolate async test artifacts to temporary directory per worker.

Sequence Diagram

sequenceDiagram
    participant Worker1 as Test Worker 1
    participant Worker2 as Test Worker 2
    participant tmpPath as tmp_path Fixture
    participant runAsync as run_async
    participant batchFile as batch.hdf5

    Worker1->>tmpPath: Get isolated tmp_dir_1
    Worker2->>tmpPath: Get isolated tmp_dir_2
    
    Worker1->>runAsync: run_async(..., path_dir=tmp_dir_1)
    Worker2->>runAsync: run_async(..., path_dir=tmp_dir_2)
    
    runAsync->>batchFile: Write to tmp_dir_1/batch.hdf5
    runAsync->>batchFile: Write to tmp_dir_2/batch.hdf5
    
    Note over Worker1,Worker2: No file contention - isolated directories
Loading

Context used:

  • Rule from dashboard - Utilize standard pytest fixtures like tmp_path (for files) and monkeypatch (for mocking state or imp... (source)

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Diff Coverage

Diff: origin/develop...HEAD, staged and unstaged changes

No lines with coverage information in this diff.

@yaugenst-flex yaugenst-flex added this pull request to the merge queue Jan 8, 2026
Merged via the queue into develop with commit aad6b55 Jan 8, 2026
73 of 85 checks passed
@yaugenst-flex yaugenst-flex deleted the FXC-4725-fix-flaky-xdist-failures-from-shared-batch-hdf-5-in-run-async-web-tests branch January 8, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants