Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/celery_backend/runner.py
# Copyright (C) 2015-2021 The Software Heritage developers | # Copyright (C) 2015-2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import logging | import logging | ||||
from typing import Dict, List, Tuple | from typing import Dict, List, Tuple | ||||
from deprecated import deprecated | |||||
from kombu.utils.uuid import uuid | from kombu.utils.uuid import uuid | ||||
from swh.core.statsd import statsd | from swh.core.statsd import statsd | ||||
from swh.scheduler import get_scheduler | from swh.scheduler import get_scheduler | ||||
from swh.scheduler.celery_backend.config import get_available_slots | from swh.scheduler.celery_backend.config import get_available_slots | ||||
from swh.scheduler.interface import SchedulerInterface | from swh.scheduler.interface import SchedulerInterface | ||||
from swh.scheduler.utils import utcnow | from swh.scheduler.utils import utcnow | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | while True: | ||||
kw = dict(task_id=backend_id, args=args, kwargs=kwargs,) | kw = dict(task_id=backend_id, args=args, kwargs=kwargs,) | ||||
if with_priority: | if with_priority: | ||||
kw["queue"] = f"save_code_now:{backend_name}" | kw["queue"] = f"save_code_now:{backend_name}" | ||||
app.send_task(backend_name, **kw) | app.send_task(backend_name, **kw) | ||||
all_backend_tasks.extend(backend_tasks) | all_backend_tasks.extend(backend_tasks) | ||||
@deprecated(version="0.18", reason="Use `swh scheduler start-runner --help` instead") | |||||
vlorentz: Don't you mean this? | |||||
ardumontAuthorUnsubmitted Done Inline Actionsyes, well i meant, please check the --help output. ardumont: yes, well i meant, please check the --help output.
But if that's enough without it, fine ;) | |||||
def main(): | def main(): | ||||
from .config import app as main_app | from .config import app as main_app | ||||
for module in main_app.conf.CELERY_IMPORTS: | for module in main_app.conf.CELERY_IMPORTS: | ||||
__import__(module) | __import__(module) | ||||
main_backend = get_scheduler("local") | main_backend = get_scheduler("local") | ||||
try: | try: | ||||
run_ready_tasks(main_backend, main_app) | run_ready_tasks(main_backend, main_app) | ||||
except Exception: | except Exception: | ||||
main_backend.rollback() | main_backend.rollback() | ||||
raise | raise | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
main() | main() |
Don't you mean this?