当前位置: 首页>>代码示例>>Python>>正文


Python Consumer.on_task_message方法代码示例

本文整理汇总了Python中celery.worker.consumer.Consumer.on_task_message方法的典型用法代码示例。如果您正苦于以下问题:Python Consumer.on_task_message方法的具体用法?Python Consumer.on_task_message怎么用?Python Consumer.on_task_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在celery.worker.consumer.Consumer的用法示例。


在下文中一共展示了Consumer.on_task_message方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import on_task_message [as 别名]
 def __init__(self, app, heartbeat=None, on_task_message=None,
              transport_driver_type=None):
     hub = Hub()
     (
         self.obj,
         self.connection,
         self.consumer,
         self.blueprint,
         self.hub,
         self.qos,
         self.heartbeat,
         self.clock,
     ) = self.args = [Mock(name='obj'),
                      Mock(name='connection'),
                      Mock(name='consumer'),
                      Mock(name='blueprint'),
                      hub,
                      Mock(name='qos'),
                      heartbeat,
                      Mock(name='clock')]
     self.connection.supports_heartbeats = True
     self.connection.get_heartbeat_interval.side_effect = (
         lambda: self.heartbeat
     )
     self.consumer.callbacks = []
     self.obj.strategies = {}
     self.connection.connection_errors = (socket.error,)
     if transport_driver_type:
         self.connection.transport.driver_type = transport_driver_type
     self.hub.readers = {}
     self.hub.writers = {}
     self.hub.consolidate = set()
     self.hub.timer = Mock(name='hub.timer')
     self.hub.timer._queue = [Mock()]
     self.hub.fire_timers = Mock(name='hub.fire_timers')
     self.hub.fire_timers.return_value = 1.7
     self.hub.poller = Mock(name='hub.poller')
     self.hub.close = Mock(name='hub.close()')  # asynloop calls hub.close
     self.Hub = self.hub
     self.blueprint.state = RUN
     # need this for create_task_handler
     _consumer = Consumer(Mock(), timer=Mock(), app=app)
     _consumer.on_task_message = on_task_message or []
     self.obj.create_task_handler = _consumer.create_task_handler
     self.on_unknown_message = self.obj.on_unknown_message = Mock(
         name='on_unknown_message',
     )
     _consumer.on_unknown_message = self.on_unknown_message
     self.on_unknown_task = self.obj.on_unknown_task = Mock(
         name='on_unknown_task',
     )
     _consumer.on_unknown_task = self.on_unknown_task
     self.on_invalid_task = self.obj.on_invalid_task = Mock(
         name='on_invalid_task',
     )
     _consumer.on_invalid_task = self.on_invalid_task
     _consumer.strategies = self.obj.strategies
开发者ID:aidan,项目名称:celery,代码行数:59,代码来源:test_loops.py

示例2: __init__

# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import on_task_message [as 别名]
 def __init__(self, app, heartbeat=None, on_task_message=None):
     hub = Hub()
     (
         self.obj,
         self.connection,
         self.consumer,
         self.blueprint,
         self.hub,
         self.qos,
         self.heartbeat,
         self.clock,
     ) = self.args = [
         Mock(name="obj"),
         Mock(name="connection"),
         Mock(name="consumer"),
         Mock(name="blueprint"),
         hub,
         Mock(name="qos"),
         heartbeat,
         Mock(name="clock"),
     ]
     self.connection.supports_heartbeats = True
     self.connection.get_heartbeat_interval.side_effect = lambda: self.heartbeat
     self.consumer.callbacks = []
     self.obj.strategies = {}
     self.connection.connection_errors = (socket.error,)
     self.hub.readers = {}
     self.hub.writers = {}
     self.hub.consolidate = set()
     self.hub.timer = Mock(name="hub.timer")
     self.hub.timer._queue = [Mock()]
     self.hub.fire_timers = Mock(name="hub.fire_timers")
     self.hub.fire_timers.return_value = 1.7
     self.hub.poller = Mock(name="hub.poller")
     self.hub.close = Mock(name="hub.close()")  # asynloop calls hub.close
     self.Hub = self.hub
     self.blueprint.state = RUN
     # need this for create_task_handler
     _consumer = Consumer(Mock(), timer=Mock(), app=app)
     _consumer.on_task_message = on_task_message or []
     self.obj.create_task_handler = _consumer.create_task_handler
     self.on_unknown_message = self.obj.on_unknown_message = Mock(name="on_unknown_message")
     _consumer.on_unknown_message = self.on_unknown_message
     self.on_unknown_task = self.obj.on_unknown_task = Mock(name="on_unknown_task")
     _consumer.on_unknown_task = self.on_unknown_task
     self.on_invalid_task = self.obj.on_invalid_task = Mock(name="on_invalid_task")
     _consumer.on_invalid_task = self.on_invalid_task
     _consumer.strategies = self.obj.strategies
开发者ID:punitx,项目名称:celery,代码行数:50,代码来源:test_loops.py


注:本文中的celery.worker.consumer.Consumer.on_task_message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。