本文整理匯總了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()
示例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
示例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?")
示例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)