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


Python tasks.cancel函数代码示例

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


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

示例1: DELETE

    def DELETE(self, task_id):
        """
        Cancel the task that is represented by the given task_id, unless it is already in a complete state.

        :param task_id: The ID of the task you wish to cancel
        :type  task_id: basestring
        """
        tasks.cancel(task_id)
        return self.ok(None)
开发者ID:aweiteka,项目名称:pulp,代码行数:9,代码来源:dispatch.py

示例2: test_cancel_after_task_canceled

    def test_cancel_after_task_canceled(self, *unused_mocks):
        """
        Test that canceling a task that was already canceled results in no change
        to the task state.
        """
        task_id = '1234abcd'
        TaskStatus(task_id, 'test_worker', state=CALL_CANCELED_STATE).save()

        tasks.cancel(task_id)
        task_status = TaskStatus.objects(task_id=task_id).first()
        self.assertEqual(task_status['state'], CALL_CANCELED_STATE)
开发者ID:hgschmie,项目名称:pulp,代码行数:11,代码来源:test_tasks.py

示例3: test_cancel_after_task_finished

    def test_cancel_after_task_finished(self, _logger, revoke):
        """
        Test that canceling a task that is already finished results in no change
        to the task state.
        """
        task_id = '1234abcd'
        TaskStatus(task_id, 'test_worker', state=CALL_FINISHED_STATE).save()

        tasks.cancel(task_id)
        task_status = TaskStatus.objects(task_id=task_id).first()
        self.assertEqual(task_status['state'], CALL_FINISHED_STATE)
开发者ID:hgschmie,项目名称:pulp,代码行数:11,代码来源:test_tasks.py

示例4: test_cancel_after_task_canceled

    def test_cancel_after_task_canceled(self, *unused_mocks):
        """
        Test that canceling a task that was already canceled results in no change
        to the task state.
        """
        task_id = '1234abcd'
        TaskStatusManager.create_task_status(task_id, 'test_worker', state=CALL_CANCELED_STATE)

        tasks.cancel(task_id)
        task_status = TaskStatusManager.find_by_task_id(task_id)
        self.assertEqual(task_status['state'], CALL_CANCELED_STATE)
开发者ID:omps,项目名称:pulp,代码行数:11,代码来源:test_tasks.py

示例5: test_cancel_after_task_finished

    def test_cancel_after_task_finished(self, logger, revoke):
        """
        Test that canceling a task that is already finished results in no change
        to the task state.
        """
        task_id = '1234abcd'
        TaskStatusManager.create_task_status(task_id, 'test_worker', state=CALL_FINISHED_STATE)

        tasks.cancel(task_id)
        task_status = TaskStatusManager.find_by_task_id(task_id)
        self.assertEqual(task_status['state'], CALL_FINISHED_STATE)
开发者ID:omps,项目名称:pulp,代码行数:11,代码来源:test_tasks.py

示例6: test_cancel_successful

    def test_cancel_successful(self, _logger, revoke):
        task_id = '1234abcd'
        TaskStatus(task_id).save()
        tasks.cancel(task_id)

        revoke.assert_called_once_with(task_id, terminate=True)
        self.assertEqual(_logger.info.call_count, 1)
        log_msg = _logger.info.mock_calls[0][1][0]
        self.assertTrue(task_id in log_msg)
        self.assertTrue('Task canceled' in log_msg)
        task_status = TaskStatus.objects(task_id=task_id).first()
        self.assertEqual(task_status['state'], CALL_CANCELED_STATE)
开发者ID:hgschmie,项目名称:pulp,代码行数:12,代码来源:test_tasks.py

示例7: test_cancel_successful

    def test_cancel_successful(self, logger, revoke):
        task_id = '1234abcd'
        TaskStatusManager.create_task_status(task_id)
        tasks.cancel(task_id)

        revoke.assert_called_once_with(task_id, terminate=True)
        self.assertEqual(logger.info.call_count, 1)
        log_msg = logger.info.mock_calls[0][1][0]
        self.assertTrue(task_id in log_msg)
        self.assertTrue('Task canceled' in log_msg)
        task_status = TaskStatusManager.find_by_task_id(task_id)
        self.assertEqual(task_status['state'], CALL_CANCELED_STATE)
开发者ID:omps,项目名称:pulp,代码行数:12,代码来源:test_tasks.py

示例8: delete

    def delete(self, request, task_id):
        """
        Dispatch tasks.cancel to delete a single task.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param task_id: The ID of the task you wish to cancel
        :type  task_id: basestring

        :return: Response containing None
        :rtype:  django.http.HttpResponse
        """
        tasks.cancel(task_id)
        return generate_json_response(None)
开发者ID:credativ,项目名称:pulp,代码行数:14,代码来源:tasks.py

示例9: test_agent_cancel

    def test_agent_cancel(self, logger, cancel, revoke):
        task_id = '1234abcd'
        consumer_id = '18d'
        tags = [
            action_tag('UNUSED'),
            resource_tag(RESOURCE_CONSUMER_TYPE, consumer_id)
        ]
        TaskStatus(task_id, tags=tags, worker_name='agent').save()
        tasks.cancel(task_id)

        cancel.assert_called_once_with(mock.ANY, consumer_id, task_id)
        self.assertFalse(revoke.called)
        self.assertEqual(logger.info.call_count, 1)
        log_msg = logger.info.mock_calls[0][1][0]
        self.assertTrue(task_id in log_msg)
        self.assertTrue('Task canceled' in log_msg)
        task_status = TaskStatus.objects(task_id=task_id).first()
        self.assertEqual(task_status['state'], CALL_CANCELED_STATE)
开发者ID:zjhuntin,项目名称:pulp,代码行数:18,代码来源:test_tasks.py

示例10: delete

    def delete(self, request, group_id):
        """
        Dispatch tasks.cancel to delete tasks in a single task_group.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param group_id: The ID of the task group you wish to cancel
        :type  group_id: basestring

        :return: Response containing None
        :rtype:  django.http.HttpResponse
        :raises MissingResource: if group id is not found
        """
        raw_tasks = TaskStatus.objects.only('task_id').filter(group_id=group_id)
        if not raw_tasks:
            raise MissingResource

        for task in raw_tasks:
            tasks.cancel(task.task_id)
        return generate_json_response(None)
开发者ID:alanoe,项目名称:pulp,代码行数:20,代码来源:task_groups.py


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