获取ChunkedEncodingError :('Connection broken:IncompleteRead

时间:2016-12-20 16:29:18

标签: python google-app-engine oauth-2.0 bigcommerce

我正在为python中的bigcommerce构建一个应用程序, 使用bigcommerce sdk(https://github.com/bigcommerce/bigcommerce-api-python) 在Google App Engine上运行 在尝试从bigcommerce获取tocken时出现以下错误:

  File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/bigcommerce/api.py", line 22, in oauth_fetch_token
    return self.connection.fetch_token(client_secret, code, context, scope, redirect_uri, token_url)
  File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/bigcommerce/connection.py", line 250, in fetch_token
    headers={'Content-Type': 'application/x-www-form-urlencoded'})
  File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/bigcommerce/connection.py", line 140, in post
    response = self._run_method('POST', url, data=data, headers=headers)
  File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/bigcommerce/connection.py", line 72, in _run_method
    return self._session.request(method, url, data=data, timeout=self.timeout, headers=headers)
  File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/requests/sessions.py", line 641, in send
    r.content
  File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/requests/models.py", line 781, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/requests/models.py", line 706, in generate
    raise ChunkedEncodingError(e)
ChunkedEncodingError: ('Connection broken: IncompleteRead(108 bytes read)', IncompleteRead(108 bytes read))

2 个答案:

答案 0 :(得分:6)

如果您在Google App Engine中使用requests,建议您使用requests_toolbelt

您可以详细了解here

在您的代码中,只需使用

即可
from requests_toolbelt.adapters import appengine
appengine.monkeypatch()

答案 1 :(得分:1)

终于找到了: 似乎请求对app引擎不起作用,但有一个修复: https://github.com/kennethreitz/requests/compare/master...agfor:master

这是我从

获取的地方

https://github.com/wooyek/flask-social-blueprint/issues/18