【发布时间】:2017-02-11 08:21:42
【问题描述】:
我正在制作一个函数来将文件从本地机器复制到远程创建线程以并行执行 sftp
def copyToServer():
//does copy file given host name and credentials
for i in hostsList:
hostname = i
username = defaultLogin
password = defaultPassword
thread = threading.Thread(target=copyToServer, args=(hostname, username, password, destPath, localPath))
threadsArray.append(thread)
thread.start()
这会创建线程并开始并行复制,但我想将其限制为一次处理 50 个线程,因为服务器总数可能太多
【问题讨论】:
标签: python multithreading paramiko python-multithreading