10

我正在尝试使用 paramiko sftp 复制大文件(~650mb)文件。我可以复制小文件,但是当我尝试复制大文件时看到以下错误。我可以直接使用 sftp 从终端复制文件。

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_file.py", line 453, in _prefetch_thread
    self.sftp._async_request(self, CMD_READ, self.handle, long(offset), int(length))
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 656, in _async_request
    self._send_packet(t, str(msg))
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp.py", line 172, in _send_packet
    self._write_all(out)
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp.py", line 136, in _write_all
    n = self.sock.send(out)
  File "/usr/lib/python2.7/dist-packages/paramiko/channel.py", line 701, in send
    self.transport._send_user_message(m)
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1426, in _send_user_message
    self._send_message(data)
  File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 1406, in _send_message
    self.packetizer.send_message(data)
  File "/usr/lib/python2.7/dist-packages/paramiko/packet.py", line 310, in send_message
    self.write_all(out)
  File "/usr/lib/python2.7/dist-packages/paramiko/packet.py", line 260, in write_all
    raise EOFError()
EOFError

Traceback (most recent call last):
  File "./extract.py", line 107, in <module>
    main()
  File "./extract.py", line 81, in main
    getFiles()
  File "./extract.py", line 58, in getFiles
    'ABC.zip')
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 614, in get
    data = fr.read(32768)
  File "/usr/lib/python2.7/dist-packages/paramiko/file.py", line 153, in read
    new_data = self._read(read_size)
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_file.py", line 152, in _read
    data = self._read_prefetch(size)
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_file.py", line 132, in _read_prefetch
    self.sftp._read_response()
  File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 668, in _read_response
    raise SSHException('Server connection dropped: %s' % (str(e),))
paramiko.SSHException: Server connection dropped: 

此外,仅在读取一定数量的字节后才会抛出此错误。我在 sftp_client.py 中引入了一个打印语句,这是输出(字节)

reading bytes data_size: 11
reading bytes data_size: 28
reading bytes data_size: 28
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776
reading bytes data_size: 32776

我不清楚为什么连接会在文件中间被丢弃。有关如何处理此问题的任何建议?

谢谢!

4

0 回答 0