3434FATAL_PATTERN = re .compile (r"\[FTL\]\s+(.*)" )
3535INFO_PATTERN = re .compile (r"\[INF\]\s+(.*)" )
3636READY_PATTERN = re .compile (r"Server is ready" )
37- LISTENING_PATTERN = re .compile (
38- r"Listening for client connections on (.+):(\d+)"
39- )
37+ LISTENING_PATTERN = re .compile (r"Listening for client connections on (.+):(\d+)" )
4038
4139
4240class ServerError (Exception ):
@@ -279,7 +277,7 @@ async def wait_ready() -> tuple[str, int]:
279277
280278 if match := LISTENING_PATTERN .search (stderr_line ):
281279 host_part = match .group (1 )
282- if host_part .startswith ('[' ) and host_part .endswith (']' ):
280+ if host_part .startswith ("[" ) and host_part .endswith ("]" ):
283281 host = host_part [1 :- 1 ]
284282 else :
285283 host = host_part
@@ -298,13 +296,11 @@ async def wait_ready() -> tuple[str, int]:
298296 if returncode != 0 :
299297 msg = f"Server exited with code { returncode } "
300298 if error_lines :
301- errors = ' \n ' .join (error_lines )
299+ errors = " \n " .join (error_lines )
302300 msg += f"\n Errors:\n { errors } "
303301 raise ServerError (msg )
304302
305- raise ServerError (
306- "Server ended without becoming ready"
307- ) # pragma: no cover
303+ raise ServerError ("Server ended without becoming ready" ) # pragma: no cover
308304
309305 return await asyncio .wait_for (wait_ready (), timeout = timeout )
310306
@@ -413,14 +409,14 @@ async def run_cluster(
413409 node_store_dir = None
414410 if jetstream and store_dir :
415411 # Use as base directory and create subdirectory for each node
416- node_store_dir = os .path .join (store_dir , f"node{ i + 1 } " )
412+ node_store_dir = os .path .join (store_dir , f"node{ i + 1 } " )
417413 os .makedirs (node_store_dir , exist_ok = True )
418414
419415 server = await _run_cluster_node (
420416 config_path = config_path ,
421417 port = available_ports [i ],
422418 routes = routes ,
423- name = f"node{ i + 1 } " ,
419+ name = f"node{ i + 1 } " ,
424420 cluster_name = "cluster" ,
425421 cluster_port = cluster_ports [i ],
426422 jetstream = jetstream ,
@@ -465,9 +461,7 @@ async def _run_cluster_node(
465461 """
466462 # Build cluster URL and routes string for CLI
467463 cluster_url = f"nats://127.0.0.1:{ cluster_port } "
468- routes_str = "," .join (
469- f"nats://127.0.0.1:{ r } " for r in routes
470- ) if routes else None
464+ routes_str = "," .join (f"nats://127.0.0.1:{ r } " for r in routes ) if routes else None
471465
472466 process = await _create_server_process (
473467 port = port ,
@@ -480,8 +474,6 @@ async def _run_cluster_node(
480474 config_path = config_path if config_path else None ,
481475 )
482476
483- assigned_host , assigned_port = await _wait_for_server_ready (
484- process , timeout = 10.0
485- )
477+ assigned_host , assigned_port = await _wait_for_server_ready (process , timeout = 10.0 )
486478
487479 return Server (process , assigned_host , assigned_port )
0 commit comments