I copied the example code from the https://asyncssh.readthedocs.io/en/latest/#sftp-client website and changed it slightly to work for my requirement.
I was able to connect to the SFTP site and download the files from the "/Exports" folder, but it seemed like the files were download one by one instead of multiple files at a time.
My code:
import asyncio
import asyncssh
import sys
async def run_client():
async with asyncssh.connect(host=host, username=username, password=password, port=port_no, known_hosts=None) as conn:
async with conn.start_sftp_client() as sftp:
await sftp.get(
remotepaths='/Exports',
localpath=r'Path on my local machine',
preserve=True,
recurse=True,
max_requests=128
)
try:
asyncio.get_event_loop().run_until_complete(run_client())
except (OSError, asyncssh.Error) as exc:
sys.exit('SFTP operation failed: ' + str(exc))
I need to download 9000 files that are mostly 1KB. I can definitely see the files downloading one by one. Any idea what the issue can be?