Google云端存储 - 使用Python库上传时出现BrokenPipeError

时间:2017-09-29 10:09:16

标签: python google-cloud-storage google-cloud-python

我有一个长期运行的Python脚本,可以将文档从MongoDB上传到GC存储。文档首先导出到本地csv文件,并且该csv文件上载到GC存储。

在出错之前,脚本运行了大约10个小时,没有任何问题。是什么导致了这个错误?

我使用GCS的代码:

client = storage.Client.from_service_account_json(KEY_JSON)

def upload_file(filepath):
    bucket = client.get_bucket(BUCKET_NAME)
    blob = bucket.blob(filepath)
    blob.upload_from_filename(filepath)

    logging.info("Uploaded file {} to GCS.", str(filepath))

堆栈追踪:

Traceback (most recent call last):
  File "/home/leonz/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/home/leonz/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 357, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.5/http/client.py", line 1107, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1152, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1103, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 936, in _send_output
    self.send(message_body)
  File "/usr/lib/python3.5/http/client.py", line 908, in send
    self.sock.sendall(data)
  File "/usr/lib/python3.5/ssl.py", line 899, in sendall
    v = self.send(data[count:])
  File "/usr/lib/python3.5/ssl.py", line 869, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 594, in write
    return self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe

0 个答案:

没有答案