Skip to content

Commit 13d8bbc

Browse files
committed
Fix SFTP code to properly handle SFTPServer's exit() being async
This commit adds code to properly call into the exit() method of the SFTPServer class when it is declared async. Thanks go to C. R. Oldham for reporting this issue!
1 parent 0b257d7 commit 13d8bbc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

asyncssh/sftp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5931,7 +5931,10 @@ async def _cleanup(self, exc: Optional[Exception]) -> None:
59315931
if inspect.isawaitable(result):
59325932
await result
59335933

5934-
self._server.exit()
5934+
result = self._server.exit()
5935+
5936+
if inspect.isawaitable(result):
5937+
await result
59355938

59365939
self._file_handles = {}
59375940
self._dir_handles = {}

tests/test_sftp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,11 @@ async def fsync(self, file_obj):
617617

618618
super().fsync(file_obj)
619619

620+
async def exit(self):
621+
"""Shut down this SFTP server"""
622+
623+
super().exit()
624+
620625

621626
class _CheckSFTP(ServerTestCase):
622627
"""Utility functions for AsyncSSH SFTP unit tests"""

0 commit comments

Comments
 (0)