本文整理汇总了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
示例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)
示例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
示例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)