Colab大規模ファイルの読み込みConnectionResetError:[Errno 104]Connection reset by peerエラー

3099 ワード

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からダウンロード