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


Python celery.VERSION属性代码示例

本文整理汇总了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 
开发者ID:getsentry,项目名称:sentry-python,代码行数:16,代码来源:test_celery.py

示例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] 
开发者ID:getsentry,项目名称:sentry-python,代码行数:36,代码来源:test_celery.py

示例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 
开发者ID:guohongze,项目名称:adminset,代码行数:12,代码来源:test_database.py

示例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") 
开发者ID:maciej-gol,项目名称:tenant-schemas-celery,代码行数:11,代码来源:app.py

示例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) 
开发者ID:maciej-gol,项目名称:tenant-schemas-celery,代码行数:11,代码来源:app.py

示例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) 
开发者ID:maciej-gol,项目名称:tenant-schemas-celery,代码行数:11,代码来源:task.py


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