Skip to content

Commit

Permalink
spec: fix max_sessions handling (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrowla authored Apr 6, 2023
1 parent c38d954 commit a62fd30
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sshfs/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import posixpath
import shlex
import stat
import threading
import weakref
from contextlib import AsyncExitStack, suppress
from datetime import datetime
Expand Down Expand Up @@ -44,8 +43,8 @@ def __init__(
host: str
SSH host to connect.
**kwargs: Any
Any option that will be passed to either the top level `AsyncFileSystem`
or the `asyncssh.connect`.
Any option that will be passed to either the top level
`AsyncFileSystem` 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
Expand All @@ -54,12 +53,14 @@ def __init__(

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

max_sessions = kwargs.pop("max_sessions", _DEFAULT_MAX_SESSIONS)
if max_sessions <= _SHELL_CHANNELS:
raise ValueError(
f"max_sessions must be greater than {_SHELL_CHANNELS}"
)
_client_args = kwargs.copy()
_client_args.setdefault("known_hosts", None)

max_sessions = kwargs.get("max_sessions", _DEFAULT_MAX_SESSIONS)
assert max_sessions > _SHELL_CHANNELS

self._stack = AsyncExitStack()
self.active_executors = 0
self._client, self._pool = self.connect(
Expand Down

0 comments on commit a62fd30

Please sign in to comment.