gpt4 book ai didi

python - 如何在 Google App Engine 中为 urlfetch 设置超时?

转载 作者:IT老高 更新时间:2023-10-28 20:57:01 26 4
gpt4 key购买 nike

我正在尝试让 Django(在 GAE 之上)从另一个 Web 服务获取数据。我经常遇到这样的错误:

ApplicationError: 2 timed out Request

Method: GET

Request URL:http://localhost:8080/

Exception Type: DownloadError

Exception Value: ApplicationError: 2 timed out

Exception Location: /google_appengine/google/appengine/api/urlfetch.py in _get_fetch_result, line 325

感觉好像只有在 12 秒后才会超时(我不确定,但确实很短)。

问题:如何设置更长的超时时间?

最佳答案

鉴于这是一个 Python 问题,我想我会为遇到此问题的任何人提供 Python 答案。

只需导入 urlfetch,然后在代码中执行任何其他操作之前定义一个截止日期:

from google.appengine.api import urlfetch

urlfetch.set_default_fetch_deadline(60)

关于python - 如何在 Google App Engine 中为 urlfetch 设置超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2162115/

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