Allow for configurable scheduler fallback period (#1759)

* Allow for configurable scheduler fallback period

This adds a parameter to the Scheduler called
`fallback_period`, which determines the period
before work fallsback to a new scheduler.

* Update defaults.py

Reduce Scheduler Fallback Period to 120 seconds.

* Update scheduler.py

Remove fallback period parameter.
This commit is contained in:
lowercase00 2023-01-25 08:57:15 -03:00 committed by GitHub
parent 9c2d353640
commit 0f5f18bec7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -8,5 +8,6 @@ DEFAULT_JOB_MONITORING_INTERVAL = 30
DEFAULT_RESULT_TTL = 500
DEFAULT_FAILURE_TTL = 31536000 # 1 year in seconds
DEFAULT_LOGGING_DATE_FORMAT = '%H:%M:%S'
DEFAULT_SCHEDULER_FALLBACK_PERIOD = 120
DEFAULT_LOGGING_FORMAT = '%(asctime)s %(message)s'
CALLBACK_TIMEOUT = 60

View File

@ -9,7 +9,8 @@ from multiprocessing import Process
from redis import SSLConnection, UnixDomainSocketConnection
from .defaults import DEFAULT_LOGGING_DATE_FORMAT, DEFAULT_LOGGING_FORMAT
from .defaults import (DEFAULT_LOGGING_DATE_FORMAT, DEFAULT_LOGGING_FORMAT,
DEFAULT_SCHEDULER_FALLBACK_PERIOD)
from .job import Job
from .logutils import setup_loghandlers
from .queue import Queue
@ -98,7 +99,7 @@ class RQScheduler:
return False
if not self.lock_acquisition_time:
return True
return (datetime.now() - self.lock_acquisition_time).total_seconds() > 600
return (datetime.now() - self.lock_acquisition_time).total_seconds() > DEFAULT_SCHEDULER_FALLBACK_PERIOD
def acquire_locks(self, auto_start=False):
"""Returns names of queue it successfully acquires lock on"""