diff --git a/tests/conftest.py b/tests/conftest.py index 80dcd0a0..72ab26e9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -482,10 +482,9 @@ def live_gui(request) -> Generator["_LiveGuiHandle", None, None]: diag = VerificationLogger("live_gui_startup", "live_gui_diag") diag.log_state("GUI Script", "N/A", "gui_2.py") - # 1. Create a per-worker subdirectory under the run workspace so xdist workers - # don't pollute the main directory or collide on port 8999. - _worker_id = os.environ.get("PYTEST_XDIST_WORKER", "master") - temp_workspace = _RUN_WORKSPACE / _worker_id + # 1. Create the run workspace (one per pytest invocation, shared by the + # single owner worker that actually runs live_gui tests). + temp_workspace = _RUN_WORKSPACE if temp_workspace.exists(): for _ in range(5): try: @@ -558,6 +557,7 @@ def live_gui(request) -> Generator["_LiveGuiHandle", None, None]: # the lock and wait for the hook server to come up, then yield a client # handle (process=None; teardown skips kill + workspace cleanup). This # serializes I/O on port 8999 so we don't try to run live_gui in parallel. + _worker_id = os.environ.get("PYTEST_XDIST_WORKER", "master") _owner_lock = temp_workspace / ".live_gui_owner.lock" _is_owner = False try: