当前位置: 首页>>代码示例>>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;未经允许,请勿转载。