本文整理汇总了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)