本文整理汇总了Python中celery.backends.cache.CacheBackend.apply_chord方法的典型用法代码示例。如果您正苦于以下问题:Python CacheBackend.apply_chord方法的具体用法?Python CacheBackend.apply_chord怎么用?Python CacheBackend.apply_chord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.backends.cache.CacheBackend
的用法示例。
在下文中一共展示了CacheBackend.apply_chord方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_on_chord_part_return
# 需要导入模块: from celery.backends.cache import CacheBackend [as 别名]
# 或者: from celery.backends.cache.CacheBackend import apply_chord [as 别名]
def test_on_chord_part_return(self, restore):
tb = CacheBackend(backend='memory://', app=self.app)
deps = Mock()
deps.__len__ = Mock()
deps.__len__.return_value = 2
restore.return_value = deps
task = Mock()
task.name = 'foobarbaz'
self.app.tasks['foobarbaz'] = task
task.request.chord = signature(task)
result = self.app.GroupResult(
uuid(),
[self.app.AsyncResult(uuid()) for _ in range(3)],
)
task.request.group = result.id
tb.apply_chord(result, None)
deps.join_native.assert_not_called()
tb.on_chord_part_return(task.request, 'SUCCESS', 10)
deps.join_native.assert_not_called()
tb.on_chord_part_return(task.request, 'SUCCESS', 10)
deps.join_native.assert_called_with(propagate=True, timeout=3.0)
deps.delete.assert_called_with()
示例2: test_apply_chord
# 需要导入模块: from celery.backends.cache import CacheBackend [as 别名]
# 或者: from celery.backends.cache.CacheBackend import apply_chord [as 别名]
def test_apply_chord(self):
tb = CacheBackend(backend='memory://', app=self.app)
result = self.app.GroupResult(
uuid(),
[self.app.AsyncResult(uuid()) for _ in range(3)],
)
tb.apply_chord(result, None)
assert self.app.GroupResult.restore(result.id, backend=tb) == result
示例3: test_on_chord_part_return
# 需要导入模块: from celery.backends.cache import CacheBackend [as 别名]
# 或者: from celery.backends.cache.CacheBackend import apply_chord [as 别名]
def test_on_chord_part_return(self, restore):
tb = CacheBackend(backend='memory://', app=self.app)
deps = Mock()
deps.__len__ = Mock()
deps.__len__.return_value = 2
restore.return_value = deps
task = Mock()
task.name = 'foobarbaz'
self.app.tasks['foobarbaz'] = task
task.request.chord = signature(task)
gid, res = uuid(), [self.app.AsyncResult(uuid()) for _ in range(3)]
task.request.group = gid
tb.apply_chord(group(app=self.app), (), gid, {}, result=res)
self.assertFalse(deps.join_native.called)
tb.on_chord_part_return(task)
self.assertFalse(deps.join_native.called)
tb.on_chord_part_return(task)
deps.join_native.assert_called_with(propagate=True)
deps.delete.assert_called_with()
示例4: test_apply_chord
# 需要导入模块: from celery.backends.cache import CacheBackend [as 别名]
# 或者: from celery.backends.cache.CacheBackend import apply_chord [as 别名]
def test_apply_chord(self):
tb = CacheBackend(backend='memory://', app=self.app)
gid, res = uuid(), [self.app.AsyncResult(uuid()) for _ in range(3)]
tb.apply_chord(group(app=self.app), (), gid, {}, result=res)