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,19 +2,18 @@
|
|||
# License: GNU General Public License version 3, or any later version
|
||||
# See top-level LICENSE file for more information
|
||||
|
||||
from ..core.tasks import ListerTaskBase
|
||||
from swh.scheduler.task import SWHTask
|
||||
from swh.scheduler.celery_backend.config import app
|
||||
|
||||
from .lister import PyPILister
|
||||
|
||||
|
||||
class PyPIListerTask(ListerTaskBase):
|
||||
"""Full PyPI lister (list all available origins from the api).
|
||||
@app.task(name='swh.lister.pypi.tasks.PyPIListerTask',
|
||||
base=SWHTask, bind=True)
|
||||
def pypi_lister(self, **lister_args):
|
||||
self.log.debug('%s(), lister_args=%s' % (
|
||||
self.name, lister_args))
|
||||
PyPILister(**lister_args).run()
|
||||
self.log.debug('%s OK' % (self.name))
|
||||
|
||||
"""
|
||||
task_queue = 'swh_lister_pypi_refresh'
|
||||
|
||||
def new_lister(self):
|
||||
return PyPILister()
|
||||
|
||||
def run_task(self):
|
||||
lister = self.new_lister()
|
||||
lister.run()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue