【问题标题】:when using ftplib in python在 python 中使用 ftplib 时
【发布时间】: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

标签: python ftplib


【解决方案1】:

也许你应该增加“timeout”选项,让服务器有更多时间响应。

【讨论】:

    【解决方案2】:

    就我而言,正如@Anders Lindahl 建议的那样,切换到 ACTV 模式后,一切都恢复了正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-27
      • 1970-01-01
      • 1970-01-01
      • 2015-06-05
      • 1970-01-01
      • 2013-06-27
      • 1970-01-01
      相关资源
      最近更新 更多