Python celery.VERSION Examples
The following are 7
code examples of celery.VERSION().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
celery
, or try the search function
.
Example #1
Source File: test_celery.py From sentry-python with BSD 2-Clause "Simplified" License | 5 votes |
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
Example #2
Source File: test_celery.py From sentry-python with BSD 2-Clause "Simplified" License | 5 votes |
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]
Example #3
Source File: test_database.py From adminset with GNU General Public License v2.0 | 5 votes |
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
Example #4
Source File: test_database.py From Adminset_Zabbix with Apache License 2.0 | 5 votes |
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
Example #5
Source File: app.py From tenant-schemas-celery with MIT License | 5 votes |
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")
Example #6
Source File: app.py From tenant-schemas-celery with MIT License | 5 votes |
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)
Example #7
Source File: task.py From tenant-schemas-celery with MIT License | 5 votes |
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)