我已将默认截止日期设置为 60 by urlfetch.set_default_fetch_deadline(60)
,但是在获取 url 时,恰好 10 秒后,它仍然会提高DeadlineExceededError
.
调用是由 API 包装器完成的,所以它不使用urlfetch
but httplib2
。但是我也已经对包装器的超时进行了修改。
编辑:一些代码
class ContextioHandler(BaseAPIHandler):
def __init__(self, request, response):
urlfetch.set_default_fetch_deadline(60)
self.cio = contextIO2.ContextIO(config.CONTEXTIO_API_KEY,
config.CONTEXTIO_API_SECRET,
timeout=60)
self.initialize(request, response)
def get(self):
account = self.cio.get_accounts(email='foo@bar.com')
account = account[0]
account.get_message('abc123')
context.io 包装库构造函数
class ContextIO(object):
url_base = "https://api.context.io"
def __init__(self, consumer_key, consumer_secret, timeout=None):
self.consumer = Consumer(key=consumer_key, secret=consumer_secret)
self.client = Client(self.consumer, timeout=timeout)
self.client.set_signature_method(sha1())
self.base_uri = '2.0'
AppEngine 日志(修剪):
...
D 2013-06-05 05:02:09.321 GET https://api.context.io/2.0/accounts?email=foo%40bar.com
D 2013-06-05 05:02:10.091 GET https://api.context.io/2.0/accounts/xyz123/messages/abc123
E 2013-06-05 05:02:19.992 Deadline exceeded while waiting for HTTP response from URL: https://api.context.io/2.0/accounts/xyz123/messages/abc123
...
D 2013-06-05 04:58:15.763 GET https://api.context.io/2.0/accounts?email=foo%40bar.com
D 2013-06-05 04:58:15.820 GET https://api.context.io/2.0/accounts/xyz123/messages/abc123
E 2013-06-05 04:58:25.715 Deadline exceeded while waiting for HTTP response from URL: https://api.context.io/2.0/accounts/xyz123/messages/abc123
...
它总是〜10秒。