May-18-2018, 02:56 PM
I want to download files using paramiko with multithreading.
But I am not sure if the paramiko's API is threading safe.
If the API is threading safe, then I can write codes as following: (python 3.6)
But I am not sure if the paramiko's API is threading safe.
If the API is threading safe, then I can write codes as following: (python 3.6)
from paramiko import SSHClient, AutoAddPolicy
from concurrent.futures import ThreadPoolExecutor
from typing import List
def dowload(files: List[str]) -> None:
client = SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
client.connect(username=.., ..)
sftp = client.open_sftp()
with ThreadPoolExecutor(10) as pool:
pool.map(lambda fn: sftp.get(fn, fn), files)Is the code right? And if there any document mentioned about the threading safe?
