From a62fd30cfcf55ef74345a0cc398f5779a1577ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Rowlands=20=28=EB=B3=80=EA=B8=B0=ED=98=B8=29?= Date: Thu, 6 Apr 2023 18:46:55 +0900 Subject: [PATCH] spec: fix max_sessions handling (#33) --- sshfs/spec.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sshfs/spec.py b/sshfs/spec.py index 9cd4ead..fc35e4c 100644 --- a/sshfs/spec.py +++ b/sshfs/spec.py @@ -2,7 +2,6 @@ import posixpath import shlex import stat -import threading import weakref from contextlib import AsyncExitStack, suppress from datetime import datetime @@ -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 @@ -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(