Colab读取大型文件ConnectionResetError: [Errno 104] Connection reset by peer报错

╰半夏微凉° 2022-04-22 03:18 442阅读 0赞

python socket 编程,sftp远程读日志文件,取最后的30行返回。收到ConnectionResetError: [Errno 104] Connection reset by peer报错。
最后找到原因是send的数据size太大,服务器端重置了连接

  1. !pip install -U -q PyDrive
  2. from pydrive.auth import GoogleAuth
  3. from pydrive.drive import GoogleDrive
  4. from google.colab import auth
  5. from oauth2client.client import GoogleCredentials
  6. # Authenticate and create the PyDrive client.
  7. # This only needs to be done once in a notebook.
  8. auth.authenticate_user()
  9. gauth = GoogleAuth()
  10. gauth.credentials = GoogleCredentials.get_application_default()
  11. drive = GoogleDrive(gauth)
  12. # Create & upload a file.
  13. uploaded = drive.CreateFile({ 'title': 'model.zip'})
  14. uploaded.SetContentFile('model.zip')
  15. uploaded.Upload()
  16. print('Uploaded file with ID {}'.format(uploaded.get('id')))

将文件保存在GoogleDrive里面,再从GoogleDrive下载

发表评论

表情:
评论列表 (有 0 条评论,442人围观)

还没有评论,来说两句吧...

相关阅读