本文整理汇总了Python中celery.VERSION属性的典型用法代码示例。如果您正苦于以下问题:Python celery.VERSION属性的具体用法?Python celery.VERSION怎么用?Python celery.VERSION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类celery
的用法示例。
在下文中一共展示了celery.VERSION属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_celery
# 需要导入模块: import celery [as 别名]
# 或者: from celery import VERSION [as 别名]
def init_celery(sentry_init):
def inner(propagate_traces=True, **kwargs):
sentry_init(
integrations=[CeleryIntegration(propagate_traces=propagate_traces)],
**kwargs
)
celery = Celery(__name__)
if VERSION < (4,):
celery.conf.CELERY_ALWAYS_EAGER = True
else:
celery.conf.task_always_eager = True
return celery
return inner
示例2: test_broken_prerun
# 需要导入模块: import celery [as 别名]
# 或者: from celery import VERSION [as 别名]
def test_broken_prerun(init_celery, connect_signal):
from celery.signals import task_prerun
stack_lengths = []
def crash(*args, **kwargs):
# scope should exist in prerun
stack_lengths.append(len(Hub.current._stack))
1 / 0
# Order here is important to reproduce the bug: In Celery 3, a crashing
# prerun would prevent other preruns from running.
connect_signal(task_prerun, crash)
celery = init_celery()
assert len(Hub.current._stack) == 1
@celery.task(name="dummy_task")
def dummy_task(x, y):
stack_lengths.append(len(Hub.current._stack))
return x / y
if VERSION >= (4,):
dummy_task.delay(2, 2)
else:
with pytest.raises(ZeroDivisionError):
dummy_task.delay(2, 2)
assert len(Hub.current._stack) == 1
if VERSION < (4,):
assert stack_lengths == [2]
else:
assert stack_lengths == [2, 2]
示例3: test_forget
# 需要导入模块: import celery [as 别名]
# 或者: from celery import VERSION [as 别名]
def test_forget(self):
tid = uuid()
self.b.mark_as_done(tid, {'foo': 'bar'})
x = self.app.AsyncResult(tid)
assert x.result.get('foo') == 'bar'
x.forget()
if celery.VERSION[0:3] == (3, 1, 10):
# bug in 3.1.10 means result did not clear cache after forget.
x._cache = None
assert x.result is None
示例4: get_schema_name_from_task
# 需要导入模块: import celery [as 别名]
# 或者: from celery import VERSION [as 别名]
def get_schema_name_from_task(task, kwargs):
if celery.VERSION[0] < 4:
# Pop it from the kwargs since tasks don't except the additional kwarg.
# This change is transparent to the system.
return kwargs.pop("_schema_name", None)
# In some cases (like Redis broker) headers are merged with `task.request`.
task_headers = task.request.headers or task.request
return task_headers.get("_schema_name")
示例5: send_task
# 需要导入模块: import celery [as 别名]
# 或者: from celery import VERSION [as 别名]
def send_task(self, name, args=None, kwargs=None, **options):
if celery.VERSION[0] < 4:
kwargs = kwargs or {}
self._add_current_schema(kwargs)
else:
# Celery 4.0 introduced strong typing and the `headers` meta dict.
self._update_headers(options)
return super(CeleryApp, self).send_task(name, args=args, kwargs=kwargs, **options)
示例6: apply
# 需要导入模块: import celery [as 别名]
# 或者: from celery import VERSION [as 别名]
def apply(self, args=None, kwargs=None, *arg, **kw):
if celery.VERSION[0] < 4:
kwargs = kwargs or {}
self._add_current_schema(kwargs)
else:
# Celery 4.0 introduced strong typing and the `headers` meta dict.
self._update_headers(kw)
return super(TenantTask, self).apply(args, kwargs, *arg, **kw)