|
|
@ -3,11 +3,11 @@ import sys
|
|
|
|
import traceback
|
|
|
|
import traceback
|
|
|
|
import uuid
|
|
|
|
import uuid
|
|
|
|
import warnings
|
|
|
|
import warnings
|
|
|
|
|
|
|
|
|
|
|
|
from collections import namedtuple
|
|
|
|
from collections import namedtuple
|
|
|
|
from datetime import datetime, timezone, timedelta
|
|
|
|
from datetime import datetime, timezone, timedelta
|
|
|
|
from functools import total_ordering
|
|
|
|
from functools import total_ordering
|
|
|
|
from typing import TYPE_CHECKING, Dict, List, Any, Callable, Optional, Tuple, Type, Union
|
|
|
|
from typing import TYPE_CHECKING, Dict, List, Any, Callable, Optional, Tuple, Type, Union
|
|
|
|
|
|
|
|
|
|
|
|
from redis import WatchError
|
|
|
|
from redis import WatchError
|
|
|
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
if TYPE_CHECKING:
|
|
|
@ -24,7 +24,6 @@ from .types import FunctionReferenceType, JobDependencyType
|
|
|
|
from .serializers import resolve_serializer
|
|
|
|
from .serializers import resolve_serializer
|
|
|
|
from .utils import backend_class, get_version, import_attribute, make_colorizer, parse_timeout, utcnow, compact
|
|
|
|
from .utils import backend_class, get_version, import_attribute, make_colorizer, parse_timeout, utcnow, compact
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
green = make_colorizer('darkgreen')
|
|
|
|
green = make_colorizer('darkgreen')
|
|
|
|
yellow = make_colorizer('darkyellow')
|
|
|
|
yellow = make_colorizer('darkyellow')
|
|
|
|
blue = make_colorizer('darkblue')
|
|
|
|
blue = make_colorizer('darkblue')
|
|
|
@ -119,7 +118,7 @@ class Queue:
|
|
|
|
prefix = cls.redis_queue_namespace_prefix
|
|
|
|
prefix = cls.redis_queue_namespace_prefix
|
|
|
|
if not queue_key.startswith(prefix):
|
|
|
|
if not queue_key.startswith(prefix):
|
|
|
|
raise ValueError('Not a valid RQ queue key: {0}'.format(queue_key))
|
|
|
|
raise ValueError('Not a valid RQ queue key: {0}'.format(queue_key))
|
|
|
|
name = queue_key[len(prefix) :]
|
|
|
|
name = queue_key[len(prefix):]
|
|
|
|
return cls(name, connection=connection, job_class=job_class, serializer=serializer)
|
|
|
|
return cls(name, connection=connection, job_class=job_class, serializer=serializer)
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
def __init__(
|
|
|
@ -196,6 +195,12 @@ class Queue:
|
|
|
|
"""Redis key used to indicate this queue has been cleaned."""
|
|
|
|
"""Redis key used to indicate this queue has been cleaned."""
|
|
|
|
return 'rq:clean_registries:%s' % self.name
|
|
|
|
return 'rq:clean_registries:%s' % self.name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def scheduler_pid(self) -> int:
|
|
|
|
|
|
|
|
from rq.scheduler import RQScheduler
|
|
|
|
|
|
|
|
pid = self.connection.get(RQScheduler.get_locking_key(self.name))
|
|
|
|
|
|
|
|
return int(pid.decode()) if pid is not None else None
|
|
|
|
|
|
|
|
|
|
|
|
def acquire_cleaning_lock(self) -> bool:
|
|
|
|
def acquire_cleaning_lock(self) -> bool:
|
|
|
|
"""Returns a boolean indicating whether a lock to clean this queue
|
|
|
|
"""Returns a boolean indicating whether a lock to clean this queue
|
|
|
|
is acquired. A lock expires in 899 seconds (15 minutes - 1 second)
|
|
|
|
is acquired. A lock expires in 899 seconds (15 minutes - 1 second)
|
|
|
|