Skip to content

Commit

Permalink
setup result ttl for healthcheck scheduler (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmet authored Sep 14, 2023
1 parent 3003475 commit c847012
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions runner_manager/jobs/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def bootstrap_healthchecks(
"group": group.name,
},
interval=settings.healthcheck_interval.total_seconds(),
# As described in the documentation of rq-scheduler, the result_ttl
# must be set to a value greater than the interval, otherwise
# the entry job with the details will expire and the job will not get
# rescheduled.
result_ttl=settings.healthcheck_interval.total_seconds() * 10,
repeat=None,
)

Expand Down
3 changes: 2 additions & 1 deletion tests/api/test_lifespan.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from rq import Queue
from rq.job import JobStatus
from rq.job import Job, JobStatus
from starlette.testclient import TestClient

from runner_manager.jobs.startup import startup


def enqueue_startup(queue: Queue) -> bool:
for job in queue.get_jobs():
job: Job
if startup == job.func:
if job.get_status() == JobStatus.QUEUED:
queue.enqueue_job(job)
Expand Down

0 comments on commit c847012

Please sign in to comment.