Instead of using the run() function here, you’re going to want to use create_process(), so you can read from stdout incrementally. In fact, since you are reading a line at a time, you can directly use the SSHReader corresponding to stdout as an async iterator which will return one line of output at a time. Here’s an example:
async with conn.create_process(‘cat /var/log/very-big-log.log') as proc:
async for line in proc.stdout:
...do whatever you need to do for each line...
One note: the variable “line” here will get the entire line, including the ‘\n’ at the end if there is one. So, you may want to operate on line.strip(‘\n’) if you don’t want that as part of your result.