Skip to content

Commit a62fd30

Browse files
authored
spec: fix max_sessions handling (#33)
1 parent c38d954 commit a62fd30

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sshfs/spec.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import posixpath
33
import shlex
44
import stat
5-
import threading
65
import weakref
76
from contextlib import AsyncExitStack, suppress
87
from datetime import datetime
@@ -44,8 +43,8 @@ def __init__(
4443
host: str
4544
SSH host to connect.
4645
**kwargs: Any
47-
Any option that will be passed to either the top level `AsyncFileSystem`
48-
or the `asyncssh.connect`.
46+
Any option that will be passed to either the top level
47+
`AsyncFileSystem` or the `asyncssh.connect`.
4948
pool_type: sshfs.pools.base.BaseSFTPChannelPool
5049
Pool manager to use (when doing concurrent operations together,
5150
pool managers offer the flexibility of prioritizing channels
@@ -54,12 +53,14 @@ def __init__(
5453

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

56+
max_sessions = kwargs.pop("max_sessions", _DEFAULT_MAX_SESSIONS)
57+
if max_sessions <= _SHELL_CHANNELS:
58+
raise ValueError(
59+
f"max_sessions must be greater than {_SHELL_CHANNELS}"
60+
)
5761
_client_args = kwargs.copy()
5862
_client_args.setdefault("known_hosts", None)
5963

60-
max_sessions = kwargs.get("max_sessions", _DEFAULT_MAX_SESSIONS)
61-
assert max_sessions > _SHELL_CHANNELS
62-
6364
self._stack = AsyncExitStack()
6465
self.active_executors = 0
6566
self._client, self._pool = self.connect(

0 commit comments

Comments
 (0)