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

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

!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

# Authenticate and create the PyDrive client.
# This only needs to be done once in a notebook.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

# Create & upload a file.
uploaded = drive.CreateFile({'title': 'model.zip'})
uploaded.SetContentFile('model.zip')
uploaded.Upload()
print('Uploaded file with ID {}'.format(uploaded.get('id')))

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

你可能感兴趣的:(Colab读取大型文件ConnectionResetError: [Errno 104] Connection reset by peer报错)