@@ -45,7 +45,9 @@ def __init__(
4545 SSH host to connect.
4646 **kwargs: Any
4747 Any option that will be passed to either the top level
48- `AsyncFileSystem` or the `asyncssh.connect`.
48+ `AsyncFileSystem` (e.g. timeout)
49+ or `asyncssh.SSHClientConnection.start_sftp_client` (e.g. env, send_env, path_encoding, path_errors, sftp_version)
50+ or the `asyncssh.connect`.
4951 pool_type: sshfs.pools.base.BaseSFTPChannelPool
5052 Pool manager to use (when doing concurrent operations together,
5153 pool managers offer the flexibility of prioritizing channels
@@ -54,6 +56,17 @@ def __init__(
5456
5557 super ().__init__ (self , ** kwargs )
5658
59+ _sftp_client_args = {
60+ k : kwargs .pop (k ) for k in kwargs .copy ().keys ()
61+ if k in {
62+ "env" ,
63+ "send_env" ,
64+ "path_encoding" ,
65+ "path_errors" ,
66+ "sftp_version" ,
67+ }
68+ }
69+ _timeout = kwargs .pop ("timeout" , None )
5770 max_sessions = kwargs .pop ("max_sessions" , _DEFAULT_MAX_SESSIONS )
5871 if max_sessions <= _SHELL_CHANNELS :
5972 raise ValueError (
@@ -68,7 +81,9 @@ def __init__(
6881 host ,
6982 pool_type ,
7083 max_sftp_channels = max_sessions - _SHELL_CHANNELS ,
71- ** _client_args ,
84+ timeout = _timeout , # goes to sync_wrapper
85+ connect_args = _client_args , # for asyncssh.connect
86+ sftp_client_args = _sftp_client_args , # for asyncssh.SSHClientConnection.start_sftp_client
7287 )
7388 weakref .finalize (
7489 self , sync , self .loop , self ._finalize , self ._pool , self ._stack
@@ -89,13 +104,13 @@ def _get_kwargs_from_urls(urlpath):
89104
90105 @wrap_exceptions
91106 async def _connect (
92- self , host , pool_type , max_sftp_channels , ** client_args
107+ self , host , pool_type , max_sftp_channels , connect_args , sftp_client_args
93108 ):
94109 self ._client_lock = asyncio .Semaphore (_SHELL_CHANNELS )
95110
96- _raw_client = asyncssh .connect (host , ** client_args )
111+ _raw_client = asyncssh .connect (host , ** connect_args )
97112 client = await self ._stack .enter_async_context (_raw_client )
98- pool = pool_type (client , max_channels = max_sftp_channels )
113+ pool = pool_type (client , max_channels = max_sftp_channels , ** sftp_client_args )
99114 return client , pool
100115
101116 connect = sync_wrapper (_connect )
0 commit comments