當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。