self.publish_to_subscribers(feed) done_msg = u"%2s ---> [%-30s] ~FYProcessed in ~FM~SB%.4ss~FY~SN (~FB%s~FY) [%s]" % ( identity, feed.feed_title[:30], delta, feed.pk, self.feed_trans[ret_feed], ) logging.debug(done_msg) total_duration = time.time() - start_duration MAnalyticsFetcher.add( feed_id=feed.pk, feed_fetch=feed_fetch_duration, feed_process=feed_process_duration, page=page_duration, icon=icon_duration, total=total_duration, feed_code=feed_code, ) self.feed_stats[ret_feed] += 1 for key, val in ret_entries.items(): self.entry_stats[key] += val if len(feed_queue) == 1: return feed # time_taken = datetime.datetime.utcnow() - self.time_start def publish_to_subscribers(self, feed):
feed.fetched_once = True try: feed = feed.save(update_fields=['last_load_time', 'fetched_once']) except IntegrityError: logging.debug(" ---> [%-30s] ~FRIntegrityError on feed: %s" % (feed.title[:30], feed.feed_address,)) if ret_entries and ret_entries['new']: self.publish_to_subscribers(feed) done_msg = (u'%2s ---> [%-30s] ~FYProcessed in ~FM~SB%.4ss~FY~SN (~FB%s~FY) [%s]' % ( identity, feed.title[:30], delta, feed.pk, self.feed_trans[ret_feed],)) logging.debug(done_msg) total_duration = time.time() - start_duration MAnalyticsFetcher.add(feed_id=feed.pk, feed_fetch=feed_fetch_duration, feed_process=feed_process_duration, page=page_duration, icon=icon_duration, total=total_duration, feed_code=feed_code) self.feed_stats[ret_feed] += 1 if len(feed_queue) == 1: return feed # time_taken = datetime.datetime.utcnow() - self.time_start def publish_to_subscribers(self, feed): try: r = redis.Redis(connection_pool=settings.REDIS_PUBSUB_POOL) listeners_count = r.publish(str(feed.pk), 'story:new') if listeners_count: logging.debug(" ---> [%-30s] ~FMPublished to %s subscribers" % (feed.title[:30], listeners_count))