Python Forum
Is the paramiko's API threading safe? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: Is the paramiko's API threading safe? (/thread-10389.html)



Is the paramiko's API threading safe? - bsxfun - May-18-2018

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)

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?Think