Replies: 4 comments 3 replies
-
Hello... I see a couple of potential problems with this code that may explain why you're getting blocked here. First, your server handle_request() code appears to be reading commands from stdin but your client code is passing the commands in as a "command" argument (creating an SSH "exec" session, not a "shell" session). The client code is not writing anything to stdin and not closing stdin, so the server code is going to block forever waiting for input on stdin. Also, note that by using a To fix this, you'd want to use Second, once this is fixed, the handle_request() function exits without doing a I don't have any direct experience with using pytest fixtures with asyncio code, so there may be additional things to consider there. However, I'd start with fixing the above issues and see how far you get. You may also find the info in https://tonybaloney.github.io/posts/async-test-patterns-for-pytest-and-unittest.html to be useful. |
Beta Was this translation helpful? Give feedback.
-
This is definitely the fastest answer I've ever seen on github ) I followed your advice and now everything works as expected:
Thank you! |
Beta Was this translation helpful? Give feedback.
-
My pleasure - glad to hear you got it working! |
Beta Was this translation helpful? Give feedback.
-
The joy was premature (( I tried to use paramiko.SSHClient instead asyncssh client with code above and and it didn't work:
I keep getting the exception:
At the same time, if I put a breakpoint on the instruction |
Beta Was this translation helpful? Give feedback.
-
For testing purposes, I made a server based on asyncssh that emulates the interactive shell of network devices. The server itself works fine if you run it separately, but does not work if you try to run it in the same event loop with the asyncssh client.
The client code blocks on the first
await conn.run(...)
while the server continues to run, which can be verified by runningssh localhost -p 8022
on the Linux command line. This makes me very sad, because I want to use this server as a fixture in pytest and want to use it like this:Could you tell me how to overcome this difficulty and achieve the desired behavior?
Beta Was this translation helpful? Give feedback.
All reactions