Reputation: 1292
I have a task handler that is making a batch request to the Google Calendar API. After 5 seconds, the request fails with DeadlineExceededError: The API call urlfetch.Fetch() took too long to respond and was cancelled. I have changed urlfetch.set_default_fetch_deadline(60)
near where I make the batch request, as suggested here but it does not seem to make a difference: the deadline seems to remain 5 seconds.
I am using the Python Google API Client library which sits on top of oauth2client and httplib2. But my understanding is that GAE intercepts the underlying calls to use urlfetch.Fetch. This is what the stack trace seems to show as well.
Can you see any reason why urlfetch.set_default_fetch_deadline
does not seem to be working?
This is the code used to build the batch request:
# 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()
Upvotes: 2
Views: 337
Reputation: 1292
So, urlfetch.set_default_fetch_deadline()
did eventually work for me. The problem was my underlying http client (oauth2client / httplib2) was essentially stored in a global. Once I created it in the task handler thread the set_default_fetch_deadline
worked.
Upvotes: 1
Reputation: 11360
Try adding the deadline
parameter:
my_result = urlfetch.fetch(my_url, deadline=15)
Upvotes: 0