gspread update_cells总是返回502并出现httpsession错误

时间:2016-08-17 18:36:57

标签: gspread

我目前正在尝试使用带有0.4.1的gspread api(版本sheet.update_cells)覆盖新的数据和谷歌电子表格,但它一直给我502错误消息,如下所示:

The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds. <ins>That’s all we know.

似乎是来自stacktrace的http会话问题:

File "/usr/local/lib/python2.7/dist-packages/gspread/models.py", line 476, in update_cells
self.client.post_cells(self, ElementTree.tostring(feed))
File "/usr/local/lib/python2.7/dist-packages/gspread/client.py", line 303, in post_cells
r = self.session.post(url, data, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/gspread/httpsession.py", line 81, in post
return self.request('POST', url, data=data, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/gspread/httpsession.py", line 67, in request
response = func(url, data=data, headers=request_headers)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 111, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 57, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request

我做了一些调查,但似乎答案有所不同,所以我觉得我应该更好的只是我的版本。

代码片段实际上没什么特别的,如下所示:

    sheet = gspread.authorize(credentials).open_by_key(spreadsheet_key).worksheet(worksheet_title)
    if not sheet:
      return
    if not len(new_rows):
      return
    sheet.resize(len(new_rows), sheet.col_count)
    active_range = 'A1:{0}{1}'.format(last_col, len(new_rows))
    cell_list = sheet.range(active_range)
    k = 0
    for row in new_rows:
      for field in row:
        cell_list[k].value = field
        k+=1

    sheet.update_cells(cell_list)

其中我的new_rows只是我要覆盖工作表的新单元格值。我不认为这是一个身份验证问题,因为相同的代码片段曾经工作,但不知何故,它在某种程度上不断给出502。

0 个答案:

没有答案