Skip to content

Commit

Permalink
create a separate parameter for SSHClientConnection options
Browse files Browse the repository at this point in the history
  • Loading branch information
ttomasz committed Jun 16, 2024
1 parent 0a8a32d commit 11024e1
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions sshfs/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import posixpath
import shlex
import stat
from typing import Optional
import weakref
from contextlib import AsyncExitStack, suppress
from datetime import datetime
Expand Down Expand Up @@ -34,6 +35,7 @@ def __init__(
host,
*,
pool_type=SFTPSoftChannelPool,
sftp_client_args: Optional[dict] = None,
**kwargs,
):
"""
Expand All @@ -46,28 +48,18 @@ def __init__(
**kwargs: Any
Any option that will be passed to either the top level
`AsyncFileSystem` (e.g. timeout)
or `asyncssh.SSHClientConnection.start_sftp_client` (e.g. env, send_env, path_encoding, path_errors, sftp_version)
or the `asyncssh.connect`.
pool_type: sshfs.pools.base.BaseSFTPChannelPool
Pool manager to use (when doing concurrent operations together,
pool managers offer the flexibility of prioritizing channels
and deciding which to use).
sftp_client_args: Optional[dict]
Parameters to pass to asyncssh.SSHClientConnection.start_sftp_client method
(e.g. env, send_env, path_encoding, path_errors, sftp_version).
"""

super().__init__(self, **kwargs)

_sftp_client_args = {
k: kwargs.pop(k)
for k in kwargs.copy().keys()
if k
in {
"env",
"send_env",
"path_encoding",
"path_errors",
"sftp_version",
}
}
_timeout = kwargs.pop("timeout", None)
max_sessions = kwargs.pop("max_sessions", _DEFAULT_MAX_SESSIONS)
if max_sessions <= _SHELL_CHANNELS:
Expand All @@ -85,7 +77,7 @@ def __init__(
max_sftp_channels=max_sessions - _SHELL_CHANNELS,
timeout=_timeout, # goes to sync_wrapper
connect_args=_client_args, # for asyncssh.connect
sftp_client_args=_sftp_client_args, # for asyncssh.SSHClientConnection.start_sftp_client
sftp_client_args=sftp_client_args or {}, # for asyncssh.SSHClientConnection.start_sftp_client
)
weakref.finalize(
self, sync, self.loop, self._finalize, self._pool, self._stack
Expand Down

0 comments on commit 11024e1

Please sign in to comment.