本文整理汇总了Python中celery.worker.consumer.Consumer.connection_errors方法的典型用法代码示例。如果您正苦于以下问题:Python Consumer.connection_errors方法的具体用法?Python Consumer.connection_errors怎么用?Python Consumer.connection_errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.worker.consumer.Consumer
的用法示例。
在下文中一共展示了Consumer.connection_errors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_consumer
# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import connection_errors [as 别名]
def get_consumer(self, no_hub=False, **kwargs):
consumer = Consumer(
on_task_request=Mock(),
init_callback=Mock(),
pool=Mock(),
app=self.app,
timer=Mock(),
controller=Mock(),
hub=None if no_hub else Mock(),
**kwargs
)
consumer.blueprint = Mock()
consumer._restart_state = Mock()
consumer.connection = Mock()
consumer.connection_errors = (socket.error, OSError, )
return consumer
示例2: test_receieve_message_ack_raises
# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import connection_errors [as 别名]
def test_receieve_message_ack_raises(self, logger, warn):
l = Consumer(self.ready_queue, timer=self.timer)
backend = Mock()
m = create_message(backend, args=[2, 4, 8], kwargs={})
l.event_dispatcher = Mock()
l.connection_errors = (socket.error, )
m.reject = Mock()
m.reject.side_effect = socket.error('foo')
callback = self._get_on_message(l)
self.assertFalse(callback(m.decode(), m))
self.assertTrue(warn.call_count)
with self.assertRaises(Empty):
self.ready_queue.get_nowait()
self.assertTrue(self.timer.empty())
m.reject.assert_called_with()
self.assertTrue(logger.critical.call_count)