Hi,
While analyzing asyncssh with python-vibe-guard, I noticed that
LocalFS.open() in asyncssh/sftp.py is defined as async def
but uses the synchronous open() builtin internally:
@async_context_manager
async def open(self, path: bytes, mode: str,
block_size: int = -1) -> LocalFile:
file_obj = open(_to_local_path(path), mode)
...
return LocalFile(file_obj)
In a server handling multiple concurrent SFTP clients on the same
event loop, each call to LocalFS.open() blocks the loop for the
duration of the file open syscall — particularly noticeable on slow
or network-mounted storage.
I wanted to ask before assuming this is a bug: was this a deliberate
design decision (e.g. LocalFS is not intended for high-concurrency
scenarios), or would a fix using asyncio.get_event_loop().run_in_executor()
or aiofiles be welcome?
Tool used: python-vibe-guard —
AST-based runtime anti-pattern scanner validated on 902 real repositories.
Hi,
While analyzing asyncssh with python-vibe-guard, I noticed that
LocalFS.open()inasyncssh/sftp.pyis defined asasync defbut uses the synchronous
open()builtin internally:In a server handling multiple concurrent SFTP clients on the same
event loop, each call to
LocalFS.open()blocks the loop for theduration of the file open syscall — particularly noticeable on slow
or network-mounted storage.
I wanted to ask before assuming this is a bug: was this a deliberate
design decision (e.g. LocalFS is not intended for high-concurrency
scenarios), or would a fix using
asyncio.get_event_loop().run_in_executor()or
aiofilesbe welcome?Tool used: python-vibe-guard —
AST-based runtime anti-pattern scanner validated on 902 real repositories.