How to run a process in asyncssh and watch its output forever?

1.3k Views Asked by At

I created a simple asyncssh app that starts a process that runs continuously. I would like to get all stdout from the app as it runs but for some reason it ends part ways. I'm not sure if this means there is a limit of how much I can get from stdout. The code is similar to the following:

async def watch_process(command): 
   async with asyncssh.connect(host=host, user=user, pass=pass) as conn: 
      async with conn.create_process(command) as proc: 
         async for line in proc.stdout: 
            printf(f"{host}: {line}")

asyncio.run(watch_process(command))

UPDATE1: I just took a look at the asyncssh email list and it appears the above code is correct, so I'm a bit perplexed that my process prints out only a portion of the lines and then hangs. https://groups.google.com/g/asyncssh-users/c/DiwRpZpYQjM/m/5uklhe01AwAJ

UPDATE2: After letting the application run for a few hours with asyncssh, I got console output every X# of lines. It seems like it had to fill a buffer past a threshold before it would print out. Is there a theshold setting in SSH that I need to configure so that it prints out each line instead of every X# of lines?

0

There are 0 best solutions below