2424import  asyncio 
2525from  pathlib  import  Path 
2626
27+ 
2728async  def  stream_output (stream , name , pipe_type , buffer ):
2829    """Asynchronously read output stream and print to console, also store in memory buffer""" 
2930    while  True :
@@ -34,13 +35,10 @@ async def stream_output(stream, name, pipe_type, buffer):
3435        print (f"[{ name } { text }  )
3536        buffer .append (text )
3637
38+ 
3739async  def  run (cmd , name , buffer ):
3840    """Start a subprocess and launch the logging coroutine""" 
39-     proc  =  await  asyncio .create_subprocess_exec (
40-         * cmd ,
41-         stdout = asyncio .subprocess .PIPE ,
42-         stderr = asyncio .subprocess .PIPE 
43-     )
41+     proc  =  await  asyncio .create_subprocess_exec (* cmd , stdout = asyncio .subprocess .PIPE , stderr = asyncio .subprocess .PIPE )
4442    print (f"{ name } { proc .pid }  )
4543
4644    # concurrently monitor stdout and stderr 
@@ -49,6 +47,7 @@ async def run(cmd, name, buffer):
4947
5048    return  proc 
5149
50+ 
5251async  def  main ():
5352    # prepare in-memory buffers for each process 
5453    server_buffer  =  []
@@ -67,8 +66,9 @@ async def main():
6766
6867    print ("Logs saved to legacy_apo_server.log and legacy_apo_client.log" )
6968
69+ 
7070if  __name__  ==  "__main__" :
7171    try :
7272        asyncio .run (main ())
7373    except  KeyboardInterrupt :
74-         print ("\n Interrupted by user, cleaning up..." )
74+         print ("\n Interrupted by user, cleaning up..." )
0 commit comments