Permalink
Browse files

Handle Google Reader API errors when trying to advance feed playbacks…

… better.
  • Loading branch information...
1 parent 3993159 commit 1af7f5c70c0975ef4527e62f53f2381c333fb49d @mihaip committed Sep 7, 2012
Showing with 16 additions and 4 deletions.
  1. +16 −4 app/feedplayback/data.py
View
@@ -136,10 +136,22 @@ def advance(self):
item_id = feed_info.item_ids[self.position]
- googlereader.edit_item_tags(
- item_id,
- origin_stream_id='feed/%s' % self.feed_url,
- add_tags=[self.reader_stream_id])
+ # This API seems to fail most often (about one occurrence a day), so
+ # it's worth retrying inline.
+ retry_count = 0
+ while True:
+ try:
+ googlereader.edit_item_tags(
+ item_id,
+ origin_stream_id='feed/%s' % self.feed_url,
+ add_tags=[self.reader_stream_id])
+ break
+ except:
+ retry_count += 1
+ if retry_count == 5:
+ logging.error('Could not advance subscription ID %s, '
+ 'too many Google Reader API failures' % self.id)
+ return
self.position += 1
self.save()

0 comments on commit 1af7f5c

Please sign in to comment.