@@ -99,26 +99,39 @@ def setup_nodes(
99
99
100
100
self .config .hook .pytest_xdist_setupnodes (config = self .config , specs = self .specs )
101
101
self .trace ("setting up nodes" )
102
+ import threading
103
+ lock = threading .Lock ()
102
104
with ThreadPoolExecutor (max_workers = len (self .specs )) as executor :
103
105
futs = [
104
- executor .submit (self .setup_node , spec , putevent , idx )
106
+ executor .submit (self .setup_node , spec , putevent , idx , lock )
105
107
for idx , spec in enumerate (self .specs )
106
108
]
107
- return [f .result () for f in futs ]
109
+ results = [f .result () for f in futs ]
110
+ for r in results :
111
+ self .config .hook .pytest_xdist_newgateway (gateway = r .gateway )
112
+ return results
108
113
# return [self.setup_node(spec, putevent) for spec in self.specs]
109
114
110
115
def setup_node (
111
116
self ,
112
117
spec : execnet .XSpec ,
113
118
putevent : Callable [[tuple [str , dict [str , Any ]]], None ],
114
119
idx : int | None = None ,
120
+ lock = None ,
115
121
) -> WorkerController :
122
+ if lock is None :
123
+ import threading
124
+ lock = threading .Lock ()
116
125
if getattr (spec , "execmodel" , None ) != "main_thread_only" :
117
126
spec = execnet .XSpec (f"execmodel=main_thread_only//{ spec } " )
118
127
# if idx is not None:
119
128
# spec = execnet.XSpec(f"{spec}//id=gw{idx}")
129
+ print ('theoretical gateway id' , idx , spec .id )
120
130
gw = self .group .makegateway (spec )
121
- self .config .hook .pytest_xdist_newgateway (gateway = gw )
131
+ # with lock:
132
+ # print('calling pytest_xdist_newgateway with gateway id', gw.id)
133
+ # self.config.hook.pytest_xdist_newgateway(gateway=gw)
134
+ print (f"setup_node: { gw } { spec } " )
122
135
self .rsync_roots (gw )
123
136
node = WorkerController (self , gw , self .config , putevent )
124
137
# Keep the node alive.
0 commit comments