From 6fe74872020853d08d311898b0d44f41a31ed01a Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Mon, 8 Apr 2013 17:17:51 -0700 Subject: [PATCH] Forcing pipeline to flush every 1000 stories. --- apps/reader/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/reader/models.py b/apps/reader/models.py index b9123efb5..ed6a5dd2e 100644 --- a/apps/reader/models.py +++ b/apps/reader/models.py @@ -706,12 +706,17 @@ class MUserStory(mongo.Document): total = read_stories.count() print " ---> Syncing %s stories (%s)" % (total, user_id or feed_id) - pipeline = r.pipeline() + pipeline = None for i, read_story in enumerate(read_stories): + if not pipeline: + pipeline = r.pipeline() if (i+1) % 1000 == 0: print " ---> %s/%s" % (i+1, total) + pipeline.execute() + pipeline = r.pipeline() read_story.sync_redis(r, pipeline=pipeline) - pipeline.execute() + if pipeline: + pipeline.execute() class UserSubscriptionFolders(models.Model): """