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


Python result.EagerResult方法代码示例

本文整理汇总了Python中celery.result.EagerResult方法的典型用法代码示例。如果您正苦于以下问题:Python result.EagerResult方法的具体用法?Python result.EagerResult怎么用?Python result.EagerResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在celery.result的用法示例。


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

示例1: setUp

# 需要导入模块: from celery import result [as 别名]
# 或者: from celery.result import EagerResult [as 别名]
def setUp(self):
        super(PagureFlaskApiProjecttests, self).setUp()
        self.gga_patcher = patch(
            "pagure.lib.tasks.generate_gitolite_acls.delay"
        )
        self.mock_gen_acls = self.gga_patcher.start()
        task_result = EagerResult("abc-1234", True, "SUCCESS")
        self.mock_gen_acls.return_value = task_result 
开发者ID:Pagure,项目名称:pagure,代码行数:10,代码来源:test_pagure_flask_api_project.py

示例2: apply_async

# 需要导入模块: from celery import result [as 别名]
# 或者: from celery.result import EagerResult [as 别名]
def apply_async(self, args=None, kwargs=None, **options):
        """
        Attempts to queues a task.
        Will raises an AlreadyQueued exception if already queued.

        :param \*args: positional arguments passed on to the task.
        :param \*\*kwargs: keyword arguments passed on to the task.
        :keyword \*\*once: (optional)
            :param: graceful: (optional)
                If True, wouldn't raise an exception if already queued.
                Instead will return none.
            :param: timeout: (optional)
                An `int' number of seconds after which the lock will expire.
                If not set, defaults to 1 hour.
            :param: keys: (optional)

        """
        once_options = options.get('once', {})
        once_graceful = once_options.get(
            'graceful', self.once.get('graceful', False))
        once_timeout = once_options.get(
            'timeout', self.once.get('timeout', self.default_timeout))

        if not options.get('retries'):
            key = self.get_key(args, kwargs)
            try:
                self.once_backend.raise_or_lock(key, timeout=once_timeout)
            except AlreadyQueued as e:
                if once_graceful:
                    return EagerResult(None, None, states.REJECTED)
                raise e
        return super(QueueOnce, self).apply_async(args, kwargs, **options) 
开发者ID:cameronmaske,项目名称:celery-once,代码行数:34,代码来源:tasks.py

示例3: test_user_count

# 需要导入模块: from celery import result [as 别名]
# 或者: from celery.result import EagerResult [as 别名]
def test_user_count(settings):
    """A basic test to execute the get_users_count Celery task."""
    UserFactory.create_batch(3)
    settings.CELERY_TASK_ALWAYS_EAGER = True
    task_result = get_users_count.delay()
    assert isinstance(task_result, EagerResult)
    assert task_result.result == 3 
开发者ID:LucianU,项目名称:bud,代码行数:9,代码来源:test_tasks.py

示例4: test_user_count

# 需要导入模块: from celery import result [as 别名]
# 或者: from celery.result import EagerResult [as 别名]
def test_user_count(self):
        """A basic test to execute the get_users_count Celery task."""
        UserFactory.create_batch(3)

        task_result = get_users_count.delay()

        self.assertIsInstance(task_result, EagerResult)
        self.assertEqual(task_result.result, 3) 
开发者ID:jeffshek,项目名称:open,代码行数:10,代码来源:test_tasks.py


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