|
|
@ -13,8 +13,8 @@ from .connections import resolve_connection
|
|
|
|
from .defaults import DEFAULT_RESULT_TTL
|
|
|
|
from .defaults import DEFAULT_RESULT_TTL
|
|
|
|
from .exceptions import DequeueTimeout, NoSuchJobError
|
|
|
|
from .exceptions import DequeueTimeout, NoSuchJobError
|
|
|
|
from .job import Job, JobStatus
|
|
|
|
from .job import Job, JobStatus
|
|
|
|
from .utils import backend_class, import_attribute, parse_timeout, utcnow
|
|
|
|
|
|
|
|
from .serializers import resolve_serializer
|
|
|
|
from .serializers import resolve_serializer
|
|
|
|
|
|
|
|
from .utils import backend_class, import_attribute, parse_timeout, utcnow
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compact(lst):
|
|
|
|
def compact(lst):
|
|
|
@ -65,8 +65,7 @@ class Queue(object):
|
|
|
|
|
|
|
|
|
|
|
|
if 'async' in kwargs:
|
|
|
|
if 'async' in kwargs:
|
|
|
|
self._is_async = kwargs['async']
|
|
|
|
self._is_async = kwargs['async']
|
|
|
|
warnings.warn('The `async` keyword is deprecated. Use `is_async` instead',
|
|
|
|
warnings.warn('The `async` keyword is deprecated. Use `is_async` instead', DeprecationWarning)
|
|
|
|
DeprecationWarning)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# override class attribute job_class if one was passed
|
|
|
|
# override class attribute job_class if one was passed
|
|
|
|
if job_class is not None:
|
|
|
|
if job_class is not None:
|
|
|
@ -317,8 +316,7 @@ class Queue(object):
|
|
|
|
pipe.multi()
|
|
|
|
pipe.multi()
|
|
|
|
|
|
|
|
|
|
|
|
for dependency in dependencies:
|
|
|
|
for dependency in dependencies:
|
|
|
|
if dependency.get_status(
|
|
|
|
if dependency.get_status(refresh=False) != JobStatus.FINISHED:
|
|
|
|
refresh=False) != JobStatus.FINISHED:
|
|
|
|
|
|
|
|
job.set_status(JobStatus.DEFERRED, pipeline=pipe)
|
|
|
|
job.set_status(JobStatus.DEFERRED, pipeline=pipe)
|
|
|
|
job.register_dependency(pipeline=pipe)
|
|
|
|
job.register_dependency(pipeline=pipe)
|
|
|
|
job.save(pipeline=pipe)
|
|
|
|
job.save(pipeline=pipe)
|
|
|
@ -380,8 +378,7 @@ class Queue(object):
|
|
|
|
"""Creates a job to represent the delayed function call and enqueues it."""
|
|
|
|
"""Creates a job to represent the delayed function call and enqueues it."""
|
|
|
|
|
|
|
|
|
|
|
|
(f, timeout, description, result_ttl, ttl, failure_ttl,
|
|
|
|
(f, timeout, description, result_ttl, ttl, failure_ttl,
|
|
|
|
depends_on, job_id, at_front, meta, args, kwargs) = Queue.parse_args(f, *args,
|
|
|
|
depends_on, job_id, at_front, meta, args, kwargs) = Queue.parse_args(f, *args, **kwargs)
|
|
|
|
**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return self.enqueue_call(
|
|
|
|
return self.enqueue_call(
|
|
|
|
func=f, args=args, kwargs=kwargs, timeout=timeout,
|
|
|
|
func=f, args=args, kwargs=kwargs, timeout=timeout,
|
|
|
@ -395,8 +392,7 @@ class Queue(object):
|
|
|
|
from .registry import ScheduledJobRegistry
|
|
|
|
from .registry import ScheduledJobRegistry
|
|
|
|
|
|
|
|
|
|
|
|
(f, timeout, description, result_ttl, ttl, failure_ttl,
|
|
|
|
(f, timeout, description, result_ttl, ttl, failure_ttl,
|
|
|
|
depends_on, job_id, at_front, meta, args, kwargs) = Queue.parse_args(f, *args,
|
|
|
|
depends_on, job_id, at_front, meta, args, kwargs) = Queue.parse_args(f, *args, **kwargs)
|
|
|
|
**kwargs)
|
|
|
|
|
|
|
|
job = self.create_job(f, status=JobStatus.SCHEDULED, args=args, kwargs=kwargs,
|
|
|
|
job = self.create_job(f, status=JobStatus.SCHEDULED, args=args, kwargs=kwargs,
|
|
|
|
timeout=timeout, result_ttl=result_ttl, ttl=ttl,
|
|
|
|
timeout=timeout, result_ttl=result_ttl, ttl=ttl,
|
|
|
|
failure_ttl=failure_ttl, description=description,
|
|
|
|
failure_ttl=failure_ttl, description=description,
|
|
|
@ -488,8 +484,7 @@ class Queue(object):
|
|
|
|
if dependent.origin == self.name:
|
|
|
|
if dependent.origin == self.name:
|
|
|
|
self.enqueue_job(dependent, pipeline=pipe)
|
|
|
|
self.enqueue_job(dependent, pipeline=pipe)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
queue = self.__class__(name=dependent.origin,
|
|
|
|
queue = self.__class__(name=dependent.origin, connection=self.connection)
|
|
|
|
connection=self.connection)
|
|
|
|
|
|
|
|
queue.enqueue_job(dependent, pipeline=pipe)
|
|
|
|
queue.enqueue_job(dependent, pipeline=pipe)
|
|
|
|
|
|
|
|
|
|
|
|
pipe.delete(dependents_key)
|
|
|
|
pipe.delete(dependents_key)
|
|
|
@ -528,8 +523,7 @@ class Queue(object):
|
|
|
|
connection = resolve_connection(connection)
|
|
|
|
connection = resolve_connection(connection)
|
|
|
|
if timeout is not None: # blocking variant
|
|
|
|
if timeout is not None: # blocking variant
|
|
|
|
if timeout == 0:
|
|
|
|
if timeout == 0:
|
|
|
|
raise ValueError(
|
|
|
|
raise ValueError('RQ does not support indefinite timeouts. Please pick a timeout value > 0')
|
|
|
|
'RQ does not support indefinite timeouts. Please pick a timeout value > 0')
|
|
|
|
|
|
|
|
result = connection.blpop(queue_keys, timeout)
|
|
|
|
result = connection.blpop(queue_keys, timeout)
|
|
|
|
if result is None:
|
|
|
|
if result is None:
|
|
|
|
raise DequeueTimeout(timeout, queue_keys)
|
|
|
|
raise DequeueTimeout(timeout, queue_keys)
|
|
|
|