Compare commits
10 Commits
239def9be9
...
2b4372bd62
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b4372bd62 | ||
|
|
1bb1a0f62a | ||
|
|
f8ea4a23b7 | ||
|
|
68bf76dce4 | ||
|
|
28c0a72e3a | ||
|
|
9d7dcae9d2 | ||
|
|
a3374b8d5c | ||
|
|
5824f221ca | ||
|
|
6ca0790e02 | ||
|
|
b59e010821 |
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import enum
|
||||
import fnmatch
|
||||
import os
|
||||
@@ -94,15 +95,23 @@ class NodeManager:
|
||||
) -> list[WorkerController]:
|
||||
self.config.hook.pytest_xdist_setupnodes(config=self.config, specs=self.specs)
|
||||
self.trace("setting up nodes")
|
||||
return [self.setup_node(spec, putevent) for spec in self.specs]
|
||||
with ThreadPoolExecutor(max_workers=len(self.specs)) as executor:
|
||||
futs = [
|
||||
executor.submit(self.setup_node, spec, putevent, idx)
|
||||
for idx, spec in enumerate(self.specs)
|
||||
]
|
||||
return [f.result() for f in futs]
|
||||
|
||||
def setup_node(
|
||||
self,
|
||||
spec: execnet.XSpec,
|
||||
putevent: Callable[[tuple[str, dict[str, Any]]], None],
|
||||
idx: int | None = None,
|
||||
) -> WorkerController:
|
||||
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}")
|
||||
gw = self.group.makegateway(spec)
|
||||
self.config.hook.pytest_xdist_newgateway(gateway=gw)
|
||||
self.rsync_roots(gw)
|
||||
|
||||
@@ -82,11 +82,19 @@ class TestNodeManagerPopen:
|
||||
call = hookrecorder.popcall("pytest_xdist_setupnodes")
|
||||
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.id == "gw0"
|
||||
call = hookrecorder.popcall("pytest_xdist_newgateway")
|
||||
assert call.gateway.id == "gw1"
|
||||
# check expected gateways
|
||||
gw_calls = [
|
||||
hookrecorder.popcall("pytest_xdist_newgateway"),
|
||||
hookrecorder.popcall("pytest_xdist_newgateway"),
|
||||
]
|
||||
assert {c.gateway.id for c in gw_calls} == {"gw0", "gw1"}
|
||||
|
||||
for c in gw_calls:
|
||||
expected_spec = execnet.XSpec(
|
||||
f"execmodel=main_thread_only//popen//id={c.gateway.id}"
|
||||
)
|
||||
assert c.gateway.spec == expected_spec
|
||||
|
||||
assert len(hm.group) == 2
|
||||
hm.teardown_nodes()
|
||||
assert not len(hm.group)
|
||||
|
||||
Reference in New Issue
Block a user