本文整理汇总了Python中celery.worker.listener.CarrotListener.reset_connection方法的典型用法代码示例。如果您正苦于以下问题:Python CarrotListener.reset_connection方法的具体用法?Python CarrotListener.reset_connection怎么用?Python CarrotListener.reset_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.worker.listener.CarrotListener
的用法示例。
在下文中一共展示了CarrotListener.reset_connection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_receieve_message_eta
# 需要导入模块: from celery.worker.listener import CarrotListener [as 别名]
# 或者: from celery.worker.listener.CarrotListener import reset_connection [as 别名]
def test_receieve_message_eta(self):
l = CarrotListener(self.ready_queue, self.eta_schedule, self.logger,
send_events=False)
backend = MockBackend()
m = create_message(backend, task=foo_task.name,
args=[2, 4, 8], kwargs={},
eta=(datetime.now() +
timedelta(days=1)).isoformat())
l.reset_connection()
p, conf.BROKER_CONNECTION_RETRY = conf.BROKER_CONNECTION_RETRY, False
try:
l.reset_connection()
finally:
conf.BROKER_CONNECTION_RETRY = p
l.receive_message(m.decode(), m)
in_hold = self.eta_schedule.queue[0]
self.assertEqual(len(in_hold), 3)
eta, priority, entry = in_hold
task = entry.args[0]
self.assertIsInstance(task, TaskRequest)
self.assertEqual(task.task_name, foo_task.name)
self.assertEqual(task.execute(), 2 * 4 * 8)
self.assertRaises(Empty, self.ready_queue.get_nowait)
示例2: test_connection
# 需要导入模块: from celery.worker.listener import CarrotListener [as 别名]
# 或者: from celery.worker.listener.CarrotListener import reset_connection [as 别名]
def test_connection(self):
l = CarrotListener(self.ready_queue, self.eta_schedule, self.logger,
send_events=False)
l.reset_connection()
self.assertTrue(isinstance(l.connection, BrokerConnection))
l.close_connection()
self.assertTrue(l.connection is None)
self.assertTrue(l.task_consumer is None)
l.reset_connection()
self.assertTrue(isinstance(l.connection, BrokerConnection))
l.stop()
self.assertTrue(l.connection is None)
self.assertTrue(l.task_consumer is None)