当前位置: 首页>>代码示例>>Python>>正文


Python MUserStory.sync_all_redis方法代码示例

本文整理汇总了Python中apps.reader.models.MUserStory.sync_all_redis方法的典型用法代码示例。如果您正苦于以下问题:Python MUserStory.sync_all_redis方法的具体用法?Python MUserStory.sync_all_redis怎么用?Python MUserStory.sync_all_redis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apps.reader.models.MUserStory的用法示例。


在下文中一共展示了MUserStory.sync_all_redis方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_feed_wrapper

# 需要导入模块: from apps.reader.models import MUserStory [as 别名]
# 或者: from apps.reader.models.MUserStory import sync_all_redis [as 别名]
 def process_feed_wrapper(self, feed_queue):
     delta = None
     current_process = multiprocessing.current_process()
     identity = "X"
     feed = None
     
     if current_process._identity:
         identity = current_process._identity[0]
         
     for feed_id in feed_queue:
         start_duration = time.time()
         feed_fetch_duration = None
         feed_process_duration = None
         page_duration = None
         icon_duration = None
         feed_code = None
         ret_entries = None
         start_time = time.time()
         ret_feed = FEED_ERREXC
         try:
             feed = self.refresh_feed(feed_id)
             
             skip = False
             if self.options.get('fake'):
                 skip = True
                 weight = "-"
                 quick = "-"
                 rand = "-"
             elif (self.options.get('quick') and not self.options['force'] and 
                   feed.known_good and feed.fetched_once and not feed.is_push):
                 weight = feed.stories_last_month * feed.num_subscribers
                 random_weight = random.randint(1, max(weight, 1))
                 quick = float(self.options.get('quick', 0))
                 rand = random.random()
                 if random_weight < 100 and rand < quick:
                     skip = True
             if skip:
                 logging.debug('   ---> [%-30s] ~BGFaking fetch, skipping (%s/month, %s subs, %s < %s)...' % (
                     feed.title[:30],
                     weight,
                     feed.num_subscribers,
                     rand, quick))
                 continue
                 
             ffeed = FetchFeed(feed_id, self.options)
             ret_feed, fetched_feed = ffeed.fetch()
             feed_fetch_duration = time.time() - start_duration
             
             if ((fetched_feed and ret_feed == FEED_OK) or self.options['force']):
                 pfeed = ProcessFeed(feed_id, fetched_feed, self.options)
                 ret_feed, ret_entries = pfeed.process()
                 feed = pfeed.feed
                 feed_process_duration = time.time() - start_duration
                 
                 if ret_entries['new'] or self.options['force']:
                     start = time.time()
                     if not feed.known_good or not feed.fetched_once:
                         feed.known_good = True
                         feed.fetched_once = True
                         feed = feed.save()
                     if random.random() <= 0.02:
                         feed.sync_redis()
                         MUserStory.delete_old_stories(feed_id=feed.pk)
                         MUserStory.sync_all_redis(feed_id=feed.pk)
                     try:
                         self.count_unreads_for_subscribers(feed)
                     except TimeoutError:
                         logging.debug('   ---> [%-30s] Unread count took too long...' % (feed.title[:30],))
                     if self.options['verbose']:
                         logging.debug(u'   ---> [%-30s] ~FBTIME: unread count in ~FM%.4ss' % (
                                       feed.title[:30], time.time() - start))
         except KeyboardInterrupt:
             break
         except urllib2.HTTPError, e:
             logging.debug('   ---> [%-30s] ~FRFeed throws HTTP error: ~SB%s' % (unicode(feed_id)[:30], e.fp.read()))
             feed.save_feed_history(e.code, e.msg, e.fp.read())
             fetched_feed = None
         except Feed.DoesNotExist, e:
             logging.debug('   ---> [%-30s] ~FRFeed is now gone...' % (unicode(feed_id)[:30]))
             continue
开发者ID:Maxxx557,项目名称:NewsBlur,代码行数:82,代码来源:feed_fetcher.py

示例2: ProcessFeed

# 需要导入模块: from apps.reader.models import MUserStory [as 别名]
# 或者: from apps.reader.models.MUserStory import sync_all_redis [as 别名]
                if ((fetched_feed and ret_feed == FEED_OK) or self.options['force']):
                    pfeed = ProcessFeed(feed_id, fetched_feed, self.options)
                    ret_feed, ret_entries = pfeed.process()
                    feed = pfeed.feed
                    feed_process_duration = time.time() - start_duration
                    
                    if ret_entries['new'] or self.options['force']:
                        start = time.time()
                        if not feed.known_good or not feed.fetched_once:
                            feed.known_good = True
                            feed.fetched_once = True
                            feed = feed.save()
                        if random.random() <= 0.02:
                            feed.sync_redis()
                            MUserStory.delete_old_stories(feed_id=feed.pk)
                            MUserStory.sync_all_redis(feed_id=feed.pk)
                        try:
                            self.count_unreads_for_subscribers(feed)
                        except TimeoutError:
                            logging.debug('   ---> [%-30s] Unread count took too long...' % (feed.title[:30],))
                        if self.options['verbose']:
                            logging.debug(u'   ---> [%-30s] ~FBTIME: unread count in ~FM%.4ss' % (
                                          feed.title[:30], time.time() - start))
<<<<<<< HEAD
                    cache.delete('feed_stories:%s-%s-%s' % (feed.id, 0, 25))
                    # if ret_entries['new'] or ret_entries['updated'] or self.options['force']:
=======
                    # if ret_entries.get(ENTRY_NEW) or ret_entries.get(ENTRY_UPDATED) or self.options['force']:
>>>>>>> Cleaning up RSS feed header for shared stories feeds.
                    #     feed.get_stories(force=True)
            except KeyboardInterrupt:
开发者ID:speedsticko,项目名称:NewsBlur,代码行数:33,代码来源:feed_fetcher.py


注:本文中的apps.reader.models.MUserStory.sync_all_redis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。