Stop binding tasks to a specific instance of the celery app
The celery.shared_task decorator allows late-binding of tasks to any celery app, which is well suited for our "task plugin" architecture.
This commit is contained in:
parent
a64ae9641d
commit
78105940ff
11 changed files with 41 additions and 44 deletions
|
@ -4,8 +4,7 @@
|
|||
|
||||
import random
|
||||
|
||||
from celery import group
|
||||
from swh.scheduler.celery_backend.config import app
|
||||
from celery import group, shared_task
|
||||
|
||||
from .. import utils
|
||||
from .lister import GitLabLister
|
||||
|
@ -14,7 +13,7 @@ from .lister import GitLabLister
|
|||
NBPAGES = 10
|
||||
|
||||
|
||||
@app.task(name=__name__ + '.IncrementalGitLabLister')
|
||||
@shared_task(name=__name__ + '.IncrementalGitLabLister')
|
||||
def list_gitlab_incremental(**lister_args):
|
||||
"""Incremental update of a GitLab instance"""
|
||||
lister_args['sort'] = 'desc'
|
||||
|
@ -24,13 +23,13 @@ def list_gitlab_incremental(**lister_args):
|
|||
lister.run(min_bound=1, max_bound=total_pages, check_existence=True)
|
||||
|
||||
|
||||
@app.task(name=__name__ + '.RangeGitLabLister')
|
||||
@shared_task(name=__name__ + '.RangeGitLabLister')
|
||||
def _range_gitlab_lister(start, end, **lister_args):
|
||||
lister = GitLabLister(**lister_args)
|
||||
lister.run(min_bound=start, max_bound=end)
|
||||
|
||||
|
||||
@app.task(name=__name__ + '.FullGitLabRelister', bind=True)
|
||||
@shared_task(name=__name__ + '.FullGitLabRelister', bind=True)
|
||||
def list_gitlab_full(self, **lister_args):
|
||||
"""Full update of a GitLab instance"""
|
||||
lister = GitLabLister(**lister_args)
|
||||
|
@ -47,6 +46,6 @@ def list_gitlab_full(self, **lister_args):
|
|||
return promise.id
|
||||
|
||||
|
||||
@app.task(name=__name__ + '.ping')
|
||||
@shared_task(name=__name__ + '.ping')
|
||||
def _ping():
|
||||
return 'OK'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue