本文整理汇总了Python中celery.worker.consumer.Consumer.update_strategies方法的典型用法代码示例。如果您正苦于以下问题:Python Consumer.update_strategies方法的具体用法?Python Consumer.update_strategies怎么用?Python Consumer.update_strategies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.worker.consumer.Consumer
的用法示例。
在下文中一共展示了Consumer.update_strategies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_receieve_message
# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import update_strategies [as 别名]
def test_receieve_message(self):
l = Consumer(self.ready_queue, timer=self.timer)
m = create_message(Mock(), task=foo_task.name,
args=[2, 4, 8], kwargs={})
l.update_strategies()
callback = self._get_on_message(l)
callback(m.decode(), m)
in_bucket = self.ready_queue.get_nowait()
self.assertIsInstance(in_bucket, Request)
self.assertEqual(in_bucket.name, foo_task.name)
self.assertEqual(in_bucket.execute(), 2 * 4 * 8)
self.assertTrue(self.timer.empty())
示例2: T
# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import update_strategies [as 别名]
import sys
@task(accept_magic_kwargs=False)
def T():
pass
tid = uuid()
P = TaskPool()
hostname = socket.gethostname()
task = {'task': T.name, 'args': (), 'kwargs': {}, 'id': tid, 'flags': 0}
app = current_app._get_current_object()
ready_queue = Queue()
def on_put(req):
req.execute_using_pool(P)
def on_ack(*a): pass
m = Message(None, {}, {}, task)
ready_queue.put = on_put
x = Consumer(ready_queue, hostname=hostname, app=app)
x.update_strategies()
name = T.name
ts = time()
for i in range(100000):
x.strategies[name](m, m.body, on_ack)
print(time() - ts)