@@ -45,7 +45,9 @@ def __init__(
45
45
SSH host to connect.
46
46
**kwargs: Any
47
47
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`.
49
51
pool_type: sshfs.pools.base.BaseSFTPChannelPool
50
52
Pool manager to use (when doing concurrent operations together,
51
53
pool managers offer the flexibility of prioritizing channels
@@ -54,6 +56,17 @@ def __init__(
54
56
55
57
super ().__init__ (self , ** kwargs )
56
58
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 )
57
70
max_sessions = kwargs .pop ("max_sessions" , _DEFAULT_MAX_SESSIONS )
58
71
if max_sessions <= _SHELL_CHANNELS :
59
72
raise ValueError (
@@ -68,7 +81,9 @@ def __init__(
68
81
host ,
69
82
pool_type ,
70
83
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
72
87
)
73
88
weakref .finalize (
74
89
self , sync , self .loop , self ._finalize , self ._pool , self ._stack
@@ -89,13 +104,13 @@ def _get_kwargs_from_urls(urlpath):
89
104
90
105
@wrap_exceptions
91
106
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
93
108
):
94
109
self ._client_lock = asyncio .Semaphore (_SHELL_CHANNELS )
95
110
96
- _raw_client = asyncssh .connect (host , ** client_args )
111
+ _raw_client = asyncssh .connect (host , ** connect_args )
97
112
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 )
99
114
return client , pool
100
115
101
116
connect = sync_wrapper (_connect )
0 commit comments