
multiprocessing.Pool作为更高级别的界面,您可能会发现有用。
from multiprocessing import Pooldef upload(file): ftp = ftplib.FTP('domainname.com') ftp.login("username","password") f = open(x,'rb') ftp.storbinary('STOR %s' %x, f) f.close() ftp.quit()infiles = [file1,file2,file3.....filen]pool = Pool(10) # submit 10 at oncepool.map(upload,infiles)很好,因为
map其行为类似于内置函数。对于调试,只需替换
pool.map->即可
map。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)