Exemplo n.º 1
0
 def test_take_outdated(self):
     self.assertFalse(Feed.get_by_pk(self._feed.id).dt_checked)
     outdated1 = Feed.take_outdated_feeds()
     self.assertEqual(len(outdated1), 1)
     self.assertEqual(outdated1[0]['feed_id'], self._feed.id)
     self.assertTrue(Feed.get_by_pk(self._feed.id).dt_checked)
     outdated2 = Feed.take_outdated_feeds()
     self.assertEqual(len(outdated2), 0)
Exemplo n.º 2
0
def do_check_feed(ctx: ActorContext):
    rand_sec = random.random() * CHECK_FEED_SECONDS / 10
    outdate_seconds = CHECK_FEED_SECONDS + rand_sec
    feeds = Feed.take_outdated_feeds(outdate_seconds)
    expire_at = time.time() + outdate_seconds
    LOG.info('found {} feeds need sync'.format(len(feeds)))
    for feed in feeds:
        ctx.hope('worker_rss.sync_feed', dict(
            feed_id=feed['feed_id'],
            url=feed['url'],
        ), expire_at=expire_at)