Heavy refactor of the task system
Get rid of the class based task definition in favor of decorator-based task declarations. Doing so, we can get rid of core/tasks.py Task names are explicitely set to keep compatibility with task definitions in schedulers' database. This also add debug statements at the beginning and end of each lister task.
This commit is contained in:
parent
94c1eaf402
commit
2d1f0643ff
7 changed files with 183 additions and 245 deletions
|
@ -2,17 +2,16 @@
|
|||
# License: GNU General Public License version 3, or any later version
|
||||
# See top-level LICENSE file for more information
|
||||
|
||||
from swh.lister.core.tasks import ListerTaskBase
|
||||
from swh.scheduler.celery_backend.config import app
|
||||
from swh.scheduler.task import SWHTask
|
||||
|
||||
from .lister import DebianLister
|
||||
|
||||
|
||||
class DebianListerTask(ListerTaskBase):
|
||||
task_queue = 'swh_lister_debian'
|
||||
|
||||
def new_lister(self):
|
||||
return DebianLister()
|
||||
|
||||
def run_task(self, distribution):
|
||||
lister = self.new_lister()
|
||||
return lister.run(distribution)
|
||||
@app.task(name='swh.lister.debian.tasks.DebianListerTask',
|
||||
base=SWHTask, bind=True)
|
||||
def debian_lister(self, distribution, **lister_args):
|
||||
self.log.debug('%s, lister_args=%s' % (
|
||||
self.name, lister_args))
|
||||
DebianLister(**lister_args).run(distribution)
|
||||
self.log.debug('%s OK' % (self.name))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue