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