You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During my usage in gcloud(which uses httplib2) over appengine environment I got an exceptions when my request to a url took more than 5 seconds. According to google app engine documentation when you need more than 5 seconds for a request you should use: urlfetch.set_default_fetch_deadline(seconds)
So I did. But the problem exception kept happening. When using fetch, you are passing the deadline parameter by (line 1002): socket.getdefaulttimeout() or 5
but it should be in this way to support appengine users: deadline = get_default_fetch_deadline() or socket.getdefaulttimeout() or 5
Attaching my code (I'm not familiar with google3 package) :
`try:
try:
from google.appengine.api import apiproxy_stub_map
if apiproxy_stub_map.apiproxy.GetStub('urlfetch') is None:
raise ImportError # Bail out; we're not actually running on App Engine.
from google.appengine.api.urlfetch import fetch
from google.appengine.api.urlfetch import InvalidURLError
from google.appengine.api.urlfetch import get_default_fetch_deadline
except (ImportError, AttributeError):
from google3.apphosting.api import apiproxy_stub_map
if apiproxy_stub_map.apiproxy.GetStub('urlfetch') is None:
raise ImportError # Bail out; we're not actually running on App Engine.
from google3.apphosting.api.urlfetch import fetch
from google3.apphosting.api.urlfetch import InvalidURLError
def _new_fixed_fetch(validate_certificate):
def fixed_fetch(url, payload=None, method="GET", headers={},
allow_truncated=False, follow_redirects=True,
deadline=None):
if deadline is None:
deadline = get_default_fetch_deadline() or socket.getdefaulttimeout() or 5
return fetch(url, payload=payload, method=method, headers=headers,
allow_truncated=allow_truncated,
follow_redirects=follow_redirects, deadline=deadline,
validate_certificate=validate_certificate)
return fixed_fetch`
The text was updated successfully, but these errors were encountered:
Hey,
During my usage in gcloud(which uses httplib2) over appengine environment I got an exceptions when my request to a url took more than 5 seconds. According to google app engine documentation when you need more than 5 seconds for a request you should use:
urlfetch.set_default_fetch_deadline(seconds)
So I did. But the problem exception kept happening. When using fetch, you are passing the deadline parameter by (line 1002):
socket.getdefaulttimeout() or 5
but it should be in this way to support appengine users:
deadline = get_default_fetch_deadline() or socket.getdefaulttimeout() or 5
Attaching my code (I'm not familiar with google3 package) :
`try:
try:
from google.appengine.api import apiproxy_stub_map
if apiproxy_stub_map.apiproxy.GetStub('urlfetch') is None:
raise ImportError # Bail out; we're not actually running on App Engine.
from google.appengine.api.urlfetch import fetch
from google.appengine.api.urlfetch import InvalidURLError
from google.appengine.api.urlfetch import get_default_fetch_deadline
except (ImportError, AttributeError):
from google3.apphosting.api import apiproxy_stub_map
if apiproxy_stub_map.apiproxy.GetStub('urlfetch') is None:
raise ImportError # Bail out; we're not actually running on App Engine.
from google3.apphosting.api.urlfetch import fetch
from google3.apphosting.api.urlfetch import InvalidURLError
The text was updated successfully, but these errors were encountered: