|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | from collections.abc import Sequence |
| 4 | +from concurrent.futures import ThreadPoolExecutor |
4 | 5 | import enum |
5 | 6 | import fnmatch |
6 | 7 | import os |
@@ -94,15 +95,24 @@ def setup_nodes( |
94 | 95 | ) -> list[WorkerController]: |
95 | 96 | self.config.hook.pytest_xdist_setupnodes(config=self.config, specs=self.specs) |
96 | 97 | self.trace("setting up nodes") |
97 | | - return [self.setup_node(spec, putevent) for spec in self.specs] |
| 98 | + with ThreadPoolExecutor(max_workers=len(self.specs)) as executor: |
| 99 | + futs = [ |
| 100 | + executor.submit(self.setup_node, spec, putevent, idx) |
| 101 | + for idx, spec in enumerate(self.specs) |
| 102 | + ] |
| 103 | + return [f.result() for f in futs] |
| 104 | + # return [self.setup_node(spec, putevent) for spec in self.specs] |
98 | 105 |
|
99 | 106 | def setup_node( |
100 | 107 | self, |
101 | 108 | spec: execnet.XSpec, |
102 | 109 | putevent: Callable[[tuple[str, dict[str, Any]]], None], |
| 110 | + idx: int | None = None, |
103 | 111 | ) -> WorkerController: |
104 | 112 | if getattr(spec, "execmodel", None) != "main_thread_only": |
105 | 113 | spec = execnet.XSpec(f"execmodel=main_thread_only//{spec}") |
| 114 | + # if idx is not None: |
| 115 | + # spec = execnet.XSpec(f"{spec}//id=gw{idx}") |
106 | 116 | gw = self.group.makegateway(spec) |
107 | 117 | self.config.hook.pytest_xdist_newgateway(gateway=gw) |
108 | 118 | self.rsync_roots(gw) |
|
0 commit comments