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


Python celery.signals方法代碼示例

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


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

示例1: on_event

# 需要導入模塊: import celery [as 別名]
# 或者: from celery import signals [as 別名]
def on_event(self, event):
        # maintain state
        self.state.event(event)

        # only need to update state when something relevant to pending tasks is happening
        check_states = ['task-received','task-started','task-succeeded','task-failed','task-revoked']
        if not event['type'] in check_states:
            return

        active = len(self.immediate_pending_tasks) > 0
        
        # switch signals if needed
        if active and self.idle.is_set():
            self.idle.clear()
            self.active.set()
        elif not active and self.active.is_set():
            self.idle.set()
            self.active.clear() 
開發者ID:RentMethod,項目名稱:celerytest,代碼行數:20,代碼來源:worker.py

示例2: do_nothing

# 需要導入模塊: import celery [as 別名]
# 或者: from celery import signals [as 別名]
def do_nothing(**kwargs):
    # Just by connecting to this signal, we prevent Celery from setting up
    # logging - and stop it from interfering with global state
    # http://docs.celeryproject.org/en/v4.3.0/userguide/signals.html#setup-logging
    pass 
開發者ID:scoutapp,項目名稱:scout_apm_python,代碼行數:7,代碼來源:test_celery.py

示例3: run

# 需要導入模塊: import celery [as 別名]
# 或者: from celery import signals [as 別名]
def run(self):
        signals.worker_init.connect(self.on_worker_init)
        signals.worker_ready.connect(self.on_worker_ready)

        self.monitor.daemon = self.daemon
        self.monitor.start()

        worker = self.app.Worker()
        if hasattr(worker, 'start'):
            worker.start()
        elif hasattr(worker, 'run'):
            worker.run()
        else:
            raise Exception("Don't know how to start worker. Incompatible Celery?") 
開發者ID:RentMethod,項目名稱:celerytest,代碼行數:16,代碼來源:worker.py

示例4: stop

# 需要導入模塊: import celery [as 別名]
# 或者: from celery import signals [as 別名]
def stop(self):
        self.monitor.stop()

        for c in self.consumers:
            c.stop()
        
        for w in self.workers:
            w.terminate()
        
        signals.worker_init.disconnect(self.on_worker_init)
        signals.worker_ready.disconnect(self.on_worker_ready) 
開發者ID:RentMethod,項目名稱:celerytest,代碼行數:13,代碼來源:worker.py


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