1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
|
"Core exceptions raised by the Redis client"
class RedisError(Exception):
pass
class ConnectionError(RedisError):
pass
class TimeoutError(RedisError):
pass
class AuthenticationError(ConnectionError):
pass
class AuthorizationError(ConnectionError):
pass
class BusyLoadingError(ConnectionError):
pass
class InvalidResponse(RedisError):
pass
class ResponseError(RedisError):
pass
class DataError(RedisError):
pass
class PubSubError(RedisError):
pass
class WatchError(RedisError):
pass
class NoScriptError(ResponseError):
pass
class OutOfMemoryError(ResponseError):
"""
Indicates the database is full. Can only occur when either:
* Redis maxmemory-policy=noeviction
* Redis maxmemory-policy=volatile* and there are no evictable keys
For more information see `Memory optimization in Redis <https://redis.io/docs/management/optimization/memory-optimization/#memory-allocation>`_. # noqa
"""
pass
class ExecAbortError(ResponseError):
pass
class ReadOnlyError(ResponseError):
pass
class NoPermissionError(ResponseError):
pass
class ModuleError(ResponseError):
pass
class LockError(RedisError, ValueError):
"Errors acquiring or releasing a lock"
# NOTE: For backwards compatibility, this class derives from ValueError.
# This was originally chosen to behave like threading.Lock.
def __init__(self, message=None, lock_name=None):
self.message = message
self.lock_name = lock_name
class LockNotOwnedError(LockError):
"Error trying to extend or release a lock that is not owned (anymore)"
pass
class ChildDeadlockedError(Exception):
"Error indicating that a child process is deadlocked after a fork()"
pass
class AuthenticationWrongNumberOfArgsError(ResponseError):
"""
An error to indicate that the wrong number of args
were sent to the AUTH command
"""
pass
class RedisClusterException(Exception):
"""
Base exception for the RedisCluster client
"""
pass
class ClusterError(RedisError):
"""
Cluster errors occurred multiple times, resulting in an exhaustion of the
command execution TTL
"""
pass
class ClusterDownError(ClusterError, ResponseError):
"""
Error indicated CLUSTERDOWN error received from cluster.
By default Redis Cluster nodes stop accepting queries if they detect there
is at least a hash slot uncovered (no available node is serving it).
This way if the cluster is partially down (for example a range of hash
slots are no longer covered) the entire cluster eventually becomes
unavailable. It automatically returns available as soon as all the slots
are covered again.
"""
def __init__(self, resp):
self.args = (resp,)
self.message = resp
class AskError(ResponseError):
"""
Error indicated ASK error received from cluster.
When a slot is set as MIGRATING, the node will accept all queries that
pertain to this hash slot, but only if the key in question exists,
otherwise the query is forwarded using a -ASK redirection to the node that
is target of the migration.
src node: MIGRATING to dst node
get > ASK error
ask dst node > ASKING command
dst node: IMPORTING from src node
asking command only affects next command
any op will be allowed after asking command
"""
def __init__(self, resp):
"""should only redirect to master node"""
self.args = (resp,)
self.message = resp
slot_id, new_node = resp.split(" ")
host, port = new_node.rsplit(":", 1)
self.slot_id = int(slot_id)
self.node_addr = self.host, self.port = host, int(port)
class TryAgainError(ResponseError):
"""
Error indicated TRYAGAIN error received from cluster.
Operations on keys that don't exist or are - during resharding - split
between the source and destination nodes, will generate a -TRYAGAIN error.
"""
def __init__(self, *args, **kwargs):
pass
class ClusterCrossSlotError(ResponseError):
"""
Error indicated CROSSSLOT error received from cluster.
A CROSSSLOT error is generated when keys in a request don't hash to the
same slot.
"""
message = "Keys in request don't hash to the same slot"
class MovedError(AskError):
"""
Error indicated MOVED error received from cluster.
A request sent to a node that doesn't serve this key will be replayed with
a MOVED error that points to the correct node.
"""
pass
class MasterDownError(ClusterDownError):
"""
Error indicated MASTERDOWN error received from cluster.
Link with MASTER is down and replica-serve-stale-data is set to 'no'.
"""
pass
class SlotNotCoveredError(RedisClusterException):
"""
This error only happens in the case where the connection pool will try to
fetch what node that is covered by a given slot.
If this error is raised the client should drop the current node layout and
attempt to reconnect and refresh the node layout again
"""
pass
class MaxConnectionsError(ConnectionError):
"""
Raised when a connection pool has reached its max_connections limit.
This indicates pool exhaustion rather than an actual connection failure.
"""
pass
class CrossSlotTransactionError(RedisClusterException):
"""
Raised when a transaction or watch is triggered in a pipeline
and not all keys or all commands belong to the same slot.
"""
pass
class InvalidPipelineStack(RedisClusterException):
"""
Raised on unexpected response length on pipelines. This is
most likely a handling error on the stack.
"""
pass
|