Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean up
  • Loading branch information
sshane committed Jul 26, 2025
commit 23f52e9799ca8d0c09d105b5262b599659712f1a
16 changes: 1 addition & 15 deletions src/xdist/workermanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,39 +99,25 @@ def setup_nodes(

self.config.hook.pytest_xdist_setupnodes(config=self.config, specs=self.specs)
self.trace("setting up nodes")
import threading
lock = threading.Lock()
with ThreadPoolExecutor(max_workers=len(self.specs)) as executor:
futs = [
executor.submit(self.setup_node, spec, putevent, idx, lock)
executor.submit(self.setup_node, spec, putevent, idx)
for idx, spec in enumerate(self.specs)
]
results = [f.result() for f in futs]
for r in results:
self.config.hook.pytest_xdist_newgateway(gateway=r.gateway)
return results
# return [self.setup_node(spec, putevent) for spec in self.specs]

def setup_node(
self,
spec: execnet.XSpec,
putevent: Callable[[tuple[str, dict[str, Any]]], None],
idx: int | None = None,
lock = None,
) -> WorkerController:
if lock is None:
import threading
lock = threading.Lock()
if getattr(spec, "execmodel", None) != "main_thread_only":
spec = execnet.XSpec(f"execmodel=main_thread_only//{spec}")
# if idx is not None:
# spec = execnet.XSpec(f"{spec}//id=gw{idx}")
print('theoretical gateway id', idx, spec.id)
gw = self.group.makegateway(spec)
# with lock:
# print('calling pytest_xdist_newgateway with gateway id', gw.id)
# self.config.hook.pytest_xdist_newgateway(gateway=gw)
print(f"setup_node: {gw} {spec}")
self.rsync_roots(gw)
node = WorkerController(self, gw, self.config, putevent)
# Keep the node alive.
Expand Down
2 changes: 1 addition & 1 deletion testing/test_workermanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_popen_makegateway_events(
assert len(call.specs) == 2

call = hookrecorder.popcall("pytest_xdist_newgateway")
# assert call.gateway.spec == execnet.XSpec("execmodel=main_thread_only//popen")
assert call.gateway.spec == execnet.XSpec("execmodel=main_thread_only//popen")
assert call.gateway.id == "gw0"
call = hookrecorder.popcall("pytest_xdist_newgateway")
assert call.gateway.id == "gw1"
Expand Down
Loading