当前位置: 首页>>代码示例>>Python>>正文


Python tasks._queue_reserved_task函数代码示例

本文整理汇总了Python中pulp.server..tasks._queue_reserved_task函数的典型用法代码示例。如果您正苦于以下问题:Python _queue_reserved_task函数的具体用法?Python _queue_reserved_task怎么用?Python _queue_reserved_task使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_queue_reserved_task函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_dispatches__release_resource

 def test_dispatches__release_resource(self):
     self.mock_get_worker_for_reservation.return_value = Worker(
         name='worker1', last_heartbeat=datetime.utcnow())
     tasks._queue_reserved_task('task_name', 'my_task_id', 'my_resource_id', [1, 2], {'a': 2})
     self.mock__release_resource.apply_async.assert_called_once_with(('my_task_id',),
                                                                     routing_key='worker1',
                                                                     exchange='C.dq')
开发者ID:zjhuntin,项目名称:pulp,代码行数:7,代码来源:test_tasks.py

示例2: test_dispatches_inner_task

 def test_dispatches_inner_task(self):
     self.mock_get_worker_for_reservation.return_value = Worker(
         name='worker1', last_heartbeat=datetime.utcnow())
     tasks._queue_reserved_task('task_name', 'my_task_id', 'my_resource_id', [1, 2], {'a': 2})
     apply_async = self.mock_celery.tasks['task_name'].apply_async
     apply_async.assert_called_once_with(1, 2, a=2, routing_key='worker1', task_id='my_task_id',
                                         exchange='C.dq')
开发者ID:zjhuntin,项目名称:pulp,代码行数:7,代码来源:test_tasks.py

示例3: test_creates_and_saves_reserved_resource

 def test_creates_and_saves_reserved_resource(self):
     self.mock_get_worker_for_reservation.return_value = Worker(
         name='worker1', last_heartbeat=datetime.utcnow())
     tasks._queue_reserved_task('task_name', 'my_task_id', 'my_resource_id', [1, 2], {'a': 2})
     self.mock_reserved_resource.assert_called_once_with(task_id='my_task_id',
                                                         worker_name='worker1',
                                                         resource_id='my_resource_id')
     self.mock_reserved_resource.return_value.save.assert_called_once_with()
开发者ID:zjhuntin,项目名称:pulp,代码行数:8,代码来源:test_tasks.py

示例4: test_loops_and_sleeps_waiting_for_available_worker

    def test_loops_and_sleeps_waiting_for_available_worker(self):
        self.mock_get_worker_for_reservation.side_effect = NoWorkers()
        self.mock_get_unreserved_worker.side_effect = NoWorkers()

        class BreakOutException(Exception):
            pass

        def side_effect(*args):
            def second_call(*args):
                raise BreakOutException()
            self.mock_time.sleep.side_effect = second_call
            return None

        self.mock_time.sleep.side_effect = side_effect

        try:
            tasks._queue_reserved_task('task_name', 'my_task_id', 'my_resource_id', [1, 2],
                                       {'a': 2})
        except BreakOutException:
            pass
        else:
            self.fail('_queue_reserved_task should have raised a BreakOutException')

        self.mock_time.sleep.assert_has_calls([mock.call(0.25), mock.call(0.25)])
开发者ID:hgschmie,项目名称:pulp,代码行数:24,代码来源:test_tasks.py

示例5: test_get_unreserved_worker_breaks_out_of_loop

 def test_get_unreserved_worker_breaks_out_of_loop(self):
     self.mock_get_worker_for_reservation.side_effect = NoWorkers()
     self.mock_get_unreserved_worker.return_value = Worker('worker1', datetime.utcnow())
     tasks._queue_reserved_task('task_name', 'my_task_id', 'my_resource_id', [1, 2], {'a': 2})
     self.assertTrue(not self.mock_time.sleep.called)
开发者ID:hgschmie,项目名称:pulp,代码行数:5,代码来源:test_tasks.py

示例6: test_get_worker_for_reservation_breaks_out_of_loop

 def test_get_worker_for_reservation_breaks_out_of_loop(self):
     self.mock_get_worker_for_reservation.return_value = Worker(
         name='worker1', last_heartbeat=datetime.utcnow())
     tasks._queue_reserved_task('task_name', 'my_task_id', 'my_resource_id', [1, 2], {'a': 2})
     self.assertTrue(not self.mock_get_unreserved_worker.called)
     self.assertTrue(not self.mock_time.sleep.called)
开发者ID:zjhuntin,项目名称:pulp,代码行数:6,代码来源:test_tasks.py


注:本文中的pulp.server..tasks._queue_reserved_task函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。