0

I am fetching data from my news stream to filter it. This takes Facebook sometimes more than 5 seconds. I hit the url_fetch() timeout of Google App Engine.

Now is there any way to work around this timeout or to improve the speed with which Facebook replies to my request? This is the part where I get my exceptions:

params[u'access_token'] = self.access_token

result = json.loads(
  urlfetch.fetch(
    url=u'https://graph.facebook.com/me/home?limit=1000,
    payload=urllib.urlencode(params),
    method=urlfetch.POST,
    headers={u'Content-Type': u'application/x-www-form-urlencoded'}
  ).content)
1
  • If information from urlfetch is ultimately sent to the browser, you can also consider using jQuery $.getJSON() with Facebook's Javascript SDK to bypass this limitation.
    – Alvin K.
    Nov 19, 2011 at 23:38

2 Answers 2

0

There's nothing you can do to speed it up - how fast it is is up to facebook. You can pass the deadline argument to URLFetch to set the maximum deadline for requests (in seconds). If you're doing a lot of calls, you probably want to look into using the asynchronous API to do calls in parallel.

0

I had a similar problem with a different project. You can use the mechanize library very adequately in GAE and it allows you to specify timeouts. Just copy the folder into your GAE project and you're good to go.

Use it sparingly though as long waits really drives up costs.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.