gpt4 book ai didi

python - Google App Engine urlfetch DeadlineExceededError 推送任务处理程序运行 apiclient 批处理请求

转载 作者:太空宇宙 更新时间:2023-11-04 05:22:17 25 4
gpt4 key购买 nike

我有一个任务处理程序正在向 Google Calendar API 发出批处理请求。 5 秒后,请求因 DeadlineExceededError 失败:API 调用 urlfetch.Fetch() 响应时间过长而被取消。 我已更改 urlfetch.set_default_fetch_deadline(60)根据建议,在我发出批量请求的地方附近 here但这似乎没有什么不同:截止日期似乎仍然是 5 秒。

我正在使用位于 oauth2client 和 httplib2 之上的 Python Google API 客户端库。但我的理解是,GAE 拦截了使用 urlfetch.Fetch 的底层调用。这也是堆栈跟踪显示的内容。

您能看出 urlfetch.set_default_fetch_deadline 似乎不起作用的任何原因吗?

编辑:

这是用于构建批处理请求的代码:

# note `http` is a oauth2client authorized http client
cal = apiclient.discovery.build('calendar','v3',http=http)
req = cal.new_batch_http_request(callback=_callback)
for event in events: # anything larger than ~5 events in batch takes >5 secs
req.add(
cal.events().patch(calendarId=calid, eventId=event["id"], body=self._value)
)
urlfetch.set_default_fetch_deadline(60) # has no effect
req.execute()

最佳答案

所以,urlfetch.set_default_fetch_deadline() 最终对我有用。问题是我的底层 http 客户端 (oauth2client/httplib2) 基本上存储在一个全局的。一旦我在任务处理程序线程中创建它,set_default_fetch_deadline 就起作用了。

关于python - Google App Engine urlfetch DeadlineExceededError 推送任务处理程序运行 apiclient 批处理请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39857515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com