gpt4 book ai didi

python ftplib : low download & upload speeds when using python ftplib

转载 作者:太空宇宙 更新时间:2023-11-03 14:28:05 24 4
gpt4 key购买 nike

我想知道是否有人观察到使用 Python 的 ftplib 通过 ftp 下载或上传文件所花费的时间与通过 Windows 命令提示符或使用 Perl 执行 FTP get/put 相比非常长Net::FTP 模块。

我创建了一个类似于 http://code.activestate.com/recipes/521925-python-ftp-client/ 的简单 FTP 客户端但我无法达到在 Windows DOS 提示符下运行 FTP 或使用 perl 时获得的速度。是不是我遗漏了什么,或者是 Python ftplib 模块有问题。

如果您能阐明我使用 Python 时吞吐量低的原因,我将不胜感激。

最佳答案

问题出在 block 大小上,我使用的 block 大小为 1024,这太小了。将 block 大小增加到 250Kb 后,所有不同平台的速度都差不多。

def putfile(file=file, site=site, dir=dir, user=())
upFile = open(file, 'rb')
handle = ftplib.FTP(site)
apply(handle.login, user)
print "Upload started"
handle.storbinary('STOR ' + file, upFile, 262144)
print "Upload completed"
handle.quit()
upFile.close()

关于 python ftplib : low download & upload speeds when using python ftplib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16824765/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com