|
|
@ -7,13 +7,14 @@ from datetime import datetime
|
|
|
|
from enum import Enum
|
|
|
|
from enum import Enum
|
|
|
|
from multiprocessing import Process
|
|
|
|
from multiprocessing import Process
|
|
|
|
|
|
|
|
|
|
|
|
from redis import Redis, SSLConnection, UnixDomainSocketConnection
|
|
|
|
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
|
|
|
|
from .job import Job
|
|
|
|
from .job import Job
|
|
|
|
from .logutils import setup_loghandlers
|
|
|
|
from .logutils import setup_loghandlers
|
|
|
|
from .queue import Queue
|
|
|
|
from .queue import Queue
|
|
|
|
from .registry import ScheduledJobRegistry
|
|
|
|
from .registry import ScheduledJobRegistry
|
|
|
|
|
|
|
|
from .serializers import resolve_serializer
|
|
|
|
from .utils import current_timestamp
|
|
|
|
from .utils import current_timestamp
|
|
|
|
|
|
|
|
|
|
|
|
SCHEDULER_KEY_TEMPLATE = 'rq:scheduler:%s'
|
|
|
|
SCHEDULER_KEY_TEMPLATE = 'rq:scheduler:%s'
|
|
|
@ -35,7 +36,7 @@ class RQScheduler:
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, queues, connection, interval=1, logging_level=logging.INFO,
|
|
|
|
def __init__(self, queues, connection, interval=1, logging_level=logging.INFO,
|
|
|
|
date_format=DEFAULT_LOGGING_DATE_FORMAT,
|
|
|
|
date_format=DEFAULT_LOGGING_DATE_FORMAT,
|
|
|
|
log_format=DEFAULT_LOGGING_FORMAT):
|
|
|
|
log_format=DEFAULT_LOGGING_FORMAT, serializer=None):
|
|
|
|
self._queue_names = set(parse_names(queues))
|
|
|
|
self._queue_names = set(parse_names(queues))
|
|
|
|
self._acquired_locks = set()
|
|
|
|
self._acquired_locks = set()
|
|
|
|
self._scheduled_job_registries = []
|
|
|
|
self._scheduled_job_registries = []
|
|
|
@ -60,6 +61,7 @@ class RQScheduler:
|
|
|
|
self._connection_kwargs['unix_socket_path'] = self._connection_kwargs.pop(
|
|
|
|
self._connection_kwargs['unix_socket_path'] = self._connection_kwargs.pop(
|
|
|
|
'path'
|
|
|
|
'path'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
self.serializer = resolve_serializer(serializer)
|
|
|
|
|
|
|
|
|
|
|
|
self._connection = None
|
|
|
|
self._connection = None
|
|
|
|
self.interval = interval
|
|
|
|
self.interval = interval
|
|
|
@ -152,10 +154,12 @@ class RQScheduler:
|
|
|
|
if not job_ids:
|
|
|
|
if not job_ids:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
queue = Queue(registry.name, connection=self.connection)
|
|
|
|
queue = Queue(registry.name, connection=self.connection, serializer=self.serializer)
|
|
|
|
|
|
|
|
|
|
|
|
with self.connection.pipeline() as pipeline:
|
|
|
|
with self.connection.pipeline() as pipeline:
|
|
|
|
jobs = Job.fetch_many(job_ids, connection=self.connection)
|
|
|
|
jobs = Job.fetch_many(
|
|
|
|
|
|
|
|
job_ids, connection=self.connection, serializer=self.serializer
|
|
|
|
|
|
|
|
)
|
|
|
|
for job in jobs:
|
|
|
|
for job in jobs:
|
|
|
|
if job is not None:
|
|
|
|
if job is not None:
|
|
|
|
queue.enqueue_job(job, pipeline=pipeline)
|
|
|
|
queue.enqueue_job(job, pipeline=pipeline)
|
|
|
|