本文整理汇总了Python中celery.result.ResultSet.iterate方法的典型用法代码示例。如果您正苦于以下问题:Python ResultSet.iterate方法的具体用法?Python ResultSet.iterate怎么用?Python ResultSet.iterate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.result.ResultSet
的用法示例。
在下文中一共展示了ResultSet.iterate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_iterate_respects_subpolling_interval
# 需要导入模块: from celery.result import ResultSet [as 别名]
# 或者: from celery.result.ResultSet import iterate [as 别名]
def test_iterate_respects_subpolling_interval(self):
r1 = self.app.AsyncResult(uuid())
r2 = self.app.AsyncResult(uuid())
backend = r1.backend = r2.backend = Mock()
backend.subpolling_interval = 10
ready = r1.ready = r2.ready = Mock()
def se(*args, **kwargs):
ready.side_effect = KeyError()
return False
ready.return_value = False
ready.side_effect = se
x = ResultSet([r1, r2])
with self.dummy_copy():
with patch("celery.result.time") as _time:
with self.assertRaises(KeyError):
list(x.iterate())
_time.sleep.assert_called_with(10)
backend.subpolling_interval = 0
with patch("celery.result.time") as _time:
with self.assertRaises(KeyError):
ready.return_value = False
ready.side_effect = se
list(x.iterate())
self.assertFalse(_time.sleep.called)
示例2: test_times_out
# 需要导入模块: from celery.result import ResultSet [as 别名]
# 或者: from celery.result.ResultSet import iterate [as 别名]
def test_times_out(self):
r1 = self.app.AsyncResult(uuid)
r1.ready = Mock()
r1.ready.return_value = False
x = ResultSet([r1])
with self.dummy_copy():
with patch("celery.result.time"):
with self.assertRaises(TimeoutError):
list(x.iterate(timeout=1))