Skip to content

Commit

Permalink
Sleep when we run into Google bot detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
khamidou committed Sep 8, 2016
1 parent 60d8f1d commit 91e3a8b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions inbox/contacts/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,14 @@ def get_items(self, sync_from_dt=None, max_results=100000):
return [self._parse_contact_result(result) for result in
results]
except gdata.client.RequestError as e:
self.log.info('contact sync request failure; retrying',
message=e)
gevent.sleep(30 + random.randrange(0, 60))
if e.status == 503:
self.log.info('Ran into Google bot detection. Sleeping.',
message=e)
gevent.sleep(5 * 60 + random.randrange(0, 60))
else:
self.log.info('contact sync request failure; retrying',
message=e)
gevent.sleep(30 + random.randrange(0, 60))
except gdata.client.Unauthorized:
self.log.warning(
'Invalid access token; refreshing and retrying')
Expand Down

0 comments on commit 91e3a8b

Please sign in to comment.