【发布时间】:2011-02-09 15:32:39
【问题描述】:
这是导致错误的相关代码。
ftp = ftplib.FTP('server')
ftp.login(r'user', r'pass')
#change directories to the "incoming" folder
ftp.cwd('incoming')
fileObj = open(fromDirectory + os.sep + f, 'rb')
#push the file
try:
msg = ftp.storbinary('STOR %s' % f, fileObj)
except Exception as inst:
msg = inst
finally:
fileObj.close()
if '226' not in msg:
#handle error case
我以前从未见过这个错误,任何关于我为什么会得到它的信息都会很有用和感激。
完整的错误信息: [Errno 10060] 连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应
需要注意的是,当我手动(即打开dos-prompt并使用ftp命令推送文件)从脚本所在的同一台机器推送文件时,我没有问题。
【问题讨论】:
-
10060 看起来像是超时错误。
-
在 google 搜索中没有什么特别有用的东西,w/r/t 如何在 python 中处理。
-
@Ignacio,感谢您的帮助。但是您不必以居高临下的问题的形式提供帮助。您可以简单地说:“您无法在客户端处理服务器错误”。
-
超时可能与主动/被动 FTP 有关,正如该问题的答案所示:stackoverflow.com/questions/3451817/python-ftplib-timing-out