Replies: 2 comments 1 reply
-
The config file handling was changed to run in an executor to accommodate the "Match Exec" feature. This makes sure that the asyncio event loop keeps running for other connections if the executable run in the "Match Exec" blocks for any reason. The executor allows the new thread to block while everything else keeps on running. When the config parsing completes, the async task for the new connection then runs in the main event loop, and the thread used for the executor is returned to the pool, lasting only as long as it took to complete reading the config. What's your concern here? In theory, the executor could be avoided if the config file didn't have a "Match Exec" in it, but that would required scanning the config file twice, which might be more expensive than the overhead of running the existing parsing in its own thread. In my experience, the overhead of using the executor is quite low, especially compared to some of the other operations like the cryptographic signing and encryption. |
Beta Was this translation helpful? Give feedback.
-
You can definitely get a benefit from loading options in advance, particularly when it comes to reading any keys you might be using over and over. The same goes for other things like known_hosts. Even if functions like In the latest code in the "develop" branch, there's a new One of the things that makes this challenging is that My suggestion to you would be to focus on loading the keys in advance, or perhaps even loading up all the shared options into an Options object which can then be passed as via the "options" argument to all of the calls to |
Beta Was this translation helpful? Give feedback.
-
I don't want to use any configuration from system or user files, so I set
config=None
, and fill SSHClientConnectionOptions myself when callingasyncssh.create_connection()
.However, there is a line inside
asyncssh.connect()
that calls run_in_executor:Is there any way to avoid executing part of the code in another thread?
It seems to me, that in my case it is not optimal.
Beta Was this translation helpful? Give feedback.
All reactions