diff --git a/invenio_jobs/services/scheduler.py b/invenio_jobs/services/scheduler.py index 0dfe732..270b6fa 100644 --- a/invenio_jobs/services/scheduler.py +++ b/invenio_jobs/services/scheduler.py @@ -13,6 +13,7 @@ from celery.beat import ScheduleEntry, Scheduler, logger from invenio_db import db +from sqlalchemy import and_ from invenio_jobs.models import Job, Run, Task from invenio_jobs.tasks import execute_run @@ -97,7 +98,9 @@ def sync(self): """Sync Jobs from db to the scheduler.""" # TODO Should we also have a cleaup task for runs? "stale" run (status running, starttime > hour, Run pending for > 1 hr) with self.app.flask_app.app_context(): - jobs = Job.query.filter(Job.active == True).all() + jobs = Job.query.filter( + and_(Job.active == True, Job.schedule != None) + ).all() self.entries = {} # because some jobs might be deactivated for job in jobs: self.entries[job.id] = JobEntry.from_job(job) diff --git a/invenio_jobs/services/services.py b/invenio_jobs/services/services.py index c2c82b8..3ea604c 100644 --- a/invenio_jobs/services/services.py +++ b/invenio_jobs/services/services.py @@ -251,6 +251,7 @@ def create(self, identity, job_id, data, uow=None): execute_run, kwargs={"run_id": run.id, "kwargs": run.args}, task_id=str(run.task_id), + queue=run.queue, ) )