當前位置: 首頁>>代碼示例>>Python>>正文


Python Task.get_publisher方法代碼示例

本文整理匯總了Python中celery.task.Task.get_publisher方法的典型用法代碼示例。如果您正苦於以下問題:Python Task.get_publisher方法的具體用法?Python Task.get_publisher怎麽用?Python Task.get_publisher使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在celery.task.Task的用法示例。


在下文中一共展示了Task.get_publisher方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: handle

# 需要導入模塊: from celery.task import Task [as 別名]
# 或者: from celery.task.Task import get_publisher [as 別名]
    def handle(self, *args, **options):
        settings.LOG_TO_STREAM = True
        now = datetime.datetime.utcnow()
        
        feeds = Feed.objects.filter(
            next_scheduled_update__lte=now, 
            active=True
        ).exclude(
            active_subscribers=0
        ).order_by('?')
        
        if options['force']:
            feeds = Feed.objects.all().order_by('pk')

        print " ---> Tasking %s feeds..." % feeds.count()
        
        publisher = Task.get_publisher()

        feed_queue = []
        size = 12
        for f in feeds:
            f.queued_date = datetime.datetime.utcnow()
            f.set_next_scheduled_update()

        for feed_queue in (feeds[pos:pos + size] for pos in xrange(0, len(feeds), size)):
            print feed_queue
            feed_ids = [feed.pk for feed in feed_queue]
            print feed_ids
            UpdateFeeds.apply_async(args=(feed_ids,), queue='update_feeds', publisher=publisher)

        publisher.connection.close()
開發者ID:tosh,項目名稱:NewsBlur,代碼行數:33,代碼來源:task_feeds.py

示例2: queue_new_feeds

# 需要導入模塊: from celery.task import Task [as 別名]
# 或者: from celery.task.Task import get_publisher [as 別名]
 def queue_new_feeds(self):
     new_feeds = UserSubscription.objects.filter(user=self.user, feed__fetched_once=False).values("feed_id")
     new_feeds = list(set([f["feed_id"] for f in new_feeds]))
     logging.info(" ---> [%s] Queueing NewFeeds: (%s) %s" % (self.user, len(new_feeds), new_feeds))
     size = 4
     publisher = Task.get_publisher(exchange="new_feeds")
     for t in (new_feeds[pos : pos + size] for pos in xrange(0, len(new_feeds), size)):
         NewFeeds.apply_async(args=(t,), queue="new_feeds", publisher=publisher)
     publisher.connection.close()
開發者ID:dkeskar,項目名稱:NewsBlur,代碼行數:11,代碼來源:models.py

示例3: queue_new_feeds

# 需要導入模塊: from celery.task import Task [as 別名]
# 或者: from celery.task.Task import get_publisher [as 別名]
 def queue_new_feeds(self, new_feeds=None):
     if not new_feeds:
         new_feeds = UserSubscription.objects.filter(user=self.user, 
                                                     feed__fetched_once=False, 
                                                     active=True).values('feed_id')
         new_feeds = list(set([f['feed_id'] for f in new_feeds]))
     logging.user(self.user, "~BB~FW~SBQueueing NewFeeds: ~FC(%s) %s" % (len(new_feeds), new_feeds))
     size = 4
     publisher = Task.get_publisher(exchange="new_feeds")
     for t in (new_feeds[pos:pos + size] for pos in xrange(0, len(new_feeds), size)):
         NewFeeds.apply_async(args=(t,), queue="new_feeds", publisher=publisher)
     publisher.connection.close()   
開發者ID:aparo,項目名稱:NewsBlur,代碼行數:14,代碼來源:models.py

示例4: task_feeds

# 需要導入模塊: from celery.task import Task [as 別名]
# 或者: from celery.task.Task import get_publisher [as 別名]
    def task_feeds(cls, feeds, queue_size=12):
        print " ---> Tasking %s feeds..." % feeds.count()

        publisher = Task.get_publisher()

        feed_queue = []
        for f in feeds:
            f.queued_date = datetime.datetime.utcnow()
            f.set_next_scheduled_update()

        for feed_queue in (feeds[pos : pos + queue_size] for pos in xrange(0, len(feeds), queue_size)):
            feed_ids = [feed.pk for feed in feed_queue]
            UpdateFeeds.apply_async(args=(feed_ids,), queue="update_feeds", publisher=publisher)

        publisher.connection.close()
開發者ID:vvarp,項目名稱:NewsBlur,代碼行數:17,代碼來源:models.py


注:本文中的celery.task.Task.get_publisher方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。