本文整理汇总了Python中kafka.future.Future.is_done方法的典型用法代码示例。如果您正苦于以下问题:Python Future.is_done方法的具体用法?Python Future.is_done怎么用?Python Future.is_done使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kafka.future.Future
的用法示例。
在下文中一共展示了Future.is_done方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_queue_success_cb
# 需要导入模块: from kafka.future import Future [as 别名]
# 或者: from kafka.future.Future import is_done [as 别名]
def test_process_queue_success_cb(self):
""" Verify success callback executed on Future success"""
mock_future = Future()
mock_future.is_done = True
mock_future.value = 1
self.kafka_producer.send = MagicMock(return_value=mock_future)
with self.assertRaises(SuccessException) as context:
process_queue(self.event_queue,
"test",
self.kafka_producer,
self.success_cb,
self.error_cb)
示例2: test_process_queue
# 需要导入模块: from kafka.future import Future [as 别名]
# 或者: from kafka.future.Future import is_done [as 别名]
def test_process_queue(self):
""" Verify message queue is processed."""
mock_future = Future()
mock_future.is_done = True
mock_future.value = 1
self.kafka_producer.send = MagicMock(return_value=mock_future)
with self.assertRaises(SuccessException) as context:
process_queue(self.event_queue,
"test",
self.kafka_producer,
self.success_cb,
self.error_cb)
# Verify message queue "get" is called
self.event_queue.get.assert_called_with()
示例3: test_process_queue_error_cb
# 需要导入模块: from kafka.future import Future [as 别名]
# 或者: from kafka.future.Future import is_done [as 别名]
def test_process_queue_error_cb(self):
""" Verify error callback executed on Future exception"""
mock_future = Future()
mock_future.is_done = True
mock_future.exception = FailureException()
cb_spy = Mock(wraps=self.error_cb)
with self.assertRaises(FailureException) as context:
self.kafka_producer.send = MagicMock(return_value=mock_future)
process_queue(self.event_queue,
"test",
self.kafka_producer,
self.success_cb,
cb_spy)
# Also verify propagation of queue and message to error callback.
# Message is specified by mocking of self.event_queue.get in setUp.
cb_spy.assert_called_with(1, self.event_queue)