Any support for async read? #449
Replies: 1 comment
-
Yes. There are many ways to do this, but the your best bet is probably to use It's not exactly what you want, but you can look at the example at https://asyncssh.readthedocs.io/en/latest/#interactive-input to get a rough idea. In your case, you can probably just go into the read call without writing to process.stdin. The simplest version of this would be something like: async def run_client() -> None:
async with asyncssh.connect('localhost') as conn:
async with conn.create_process('tail -f some_file.txt') as process:
for line in process.stdin:
print(line, end='') If you want to process the output, just replace print() there with your processing code. It'll be called once for each line of output. Note that the lines will have a '\n' on the end of them already, so you may want to strip that off or otherwise account for it. |
Beta Was this translation helpful? Give feedback.
-
For long running processes (e.g. ssh -f tail), data is needed incrementally with a read or epoll/read.
Is that supported here? Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions