@@ -136,6 +136,8 @@ def get_node(self, node_id):
136136 for n in self .nodes :
137137 if n .node_id == node_id :
138138 return n
139+ from rich .pretty import pprint
140+ pprint (self .nodes )
139141 raise ValueError (
140142 f"No node with node_id={ node_id } found in gltesting scheduler, do you need to register it first?"
141143 )
@@ -264,7 +266,7 @@ async def Recover(self, req):
264266
265267 async def Schedule (self , req ):
266268 n = self .get_node (req .node_id )
267-
269+ print ( "XXX" , n )
268270 # If already running we just return the existing binding
269271 if n .process :
270272 return schedpb .NodeInfoResponse (
@@ -274,7 +276,7 @@ async def Schedule(self, req):
274276
275277 node_version = n .signer_version .get_node_version ()
276278 node_version = self .versions .get (node_version , None )
277-
279+ print ( "XXX" , node_version )
278280 logging .debug (
279281 f"Determined that we need to start node_version={ node_version } for n.signer_version={ n .signer_version } "
280282 )
@@ -284,41 +286,48 @@ async def Schedule(self, req):
284286 f"No node_version found for n.signer_version={ n .signer_version } "
285287 )
286288
287- # Otherwise we need to start a new process
288- n .process = NodeProcess (
289- node_id = req .node_id ,
290- init_msg = n .initmsg ,
291- directory = n .directory ,
292- network = n .network ,
293- identity = n .identity ,
294- version = node_version ,
295- bitcoind = self .bitcoind ,
296- startupmsgs = n .startupmsgs ,
297- )
298- n .process .write_node_config (n .network )
299- n .process .start ()
300-
301- with n .condition :
302- n .condition .notify_all ()
303-
304- # Wait for the grpc port to be accessible
305- start_time = time .perf_counter ()
306- timeout = 10
307- while True :
308- try :
309- with socket .create_connection (
310- ("localhost" , n .process .grpc_port ), timeout = 0.1
311- ):
312- break
313- except Exception :
314- time .sleep (0.01 )
315- if time .perf_counter () - start_time >= timeout :
316- raise TimeoutError (
317- f"Waited too for port localhost:{ n .process .grpc_port } to become reachable"
318- )
319- # TODO Actually wait for the port to be accessible
320- time .sleep (1 )
321-
289+ print ("XXX" ,"Starting" )
290+ try :
291+ # Otherwise we need to start a new process
292+ n .process = NodeProcess (
293+ node_id = req .node_id ,
294+ init_msg = n .initmsg ,
295+ directory = n .directory ,
296+ network = n .network ,
297+ identity = n .identity ,
298+ version = node_version ,
299+ bitcoind = self .bitcoind ,
300+ startupmsgs = n .startupmsgs ,
301+ )
302+ n .process .write_node_config (n .network )
303+ n .process .start ()
304+
305+ # Wait for the grpc port to be accessible
306+ start_time = time .perf_counter ()
307+ timeout = 10
308+ print ("Waiting for node to become reachable" )
309+ while True :
310+ try :
311+ print ("Pinging" )
312+ with socket .create_connection (
313+ ("localhost" , n .process .grpc_port ), timeout = 0.1
314+ ):
315+ print ("Successfully connected to grpc port" )
316+ break
317+ except Exception :
318+ print ("Failed to contact grpc port, sleeping" )
319+ time .sleep (0.1 )
320+ if time .perf_counter () - start_time >= timeout :
321+ raise TimeoutError (
322+ f"Waited too for port localhost:{ n .process .grpc_port } to become reachable"
323+ )
324+ # TODO Actually wait for the port to be accessible
325+ time .sleep (1 )
326+ with n .condition :
327+ n .condition .notify_all ()
328+ except Exception as e :
329+ print (e )
330+ raise e
322331 return schedpb .NodeInfoResponse (
323332 node_id = n .node_id ,
324333 grpc_uri = n .process .grpc_uri ,
0 commit comments