Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/redis/exceptions.py: 85%
72 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 06:16 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 06:16 +0000
1"Core exceptions raised by the Redis client"
4class RedisError(Exception):
5 pass
8class ConnectionError(RedisError):
9 pass
12class TimeoutError(RedisError):
13 pass
16class AuthenticationError(ConnectionError):
17 pass
20class AuthorizationError(ConnectionError):
21 pass
24class BusyLoadingError(ConnectionError):
25 pass
28class InvalidResponse(RedisError):
29 pass
32class ResponseError(RedisError):
33 pass
36class DataError(RedisError):
37 pass
40class PubSubError(RedisError):
41 pass
44class WatchError(RedisError):
45 pass
48class NoScriptError(ResponseError):
49 pass
52class OutOfMemoryError(ResponseError):
53 """
54 Indicates the database is full. Can only occur when either:
55 * Redis maxmemory-policy=noeviction
56 * Redis maxmemory-policy=volatile* and there are no evictable keys
58 For more information see `Memory optimization in Redis <https://redis.io/docs/management/optimization/memory-optimization/#memory-allocation>`_. # noqa
59 """
61 pass
64class ExecAbortError(ResponseError):
65 pass
68class ReadOnlyError(ResponseError):
69 pass
72class NoPermissionError(ResponseError):
73 pass
76class ModuleError(ResponseError):
77 pass
80class LockError(RedisError, ValueError):
81 "Errors acquiring or releasing a lock"
82 # NOTE: For backwards compatibility, this class derives from ValueError.
83 # This was originally chosen to behave like threading.Lock.
85 def __init__(self, message=None, lock_name=None):
86 self.message = message
87 self.lock_name = lock_name
90class LockNotOwnedError(LockError):
91 "Error trying to extend or release a lock that is (no longer) owned"
92 pass
95class ChildDeadlockedError(Exception):
96 "Error indicating that a child process is deadlocked after a fork()"
97 pass
100class AuthenticationWrongNumberOfArgsError(ResponseError):
101 """
102 An error to indicate that the wrong number of args
103 were sent to the AUTH command
104 """
106 pass
109class RedisClusterException(Exception):
110 """
111 Base exception for the RedisCluster client
112 """
114 pass
117class ClusterError(RedisError):
118 """
119 Cluster errors occurred multiple times, resulting in an exhaustion of the
120 command execution TTL
121 """
123 pass
126class ClusterDownError(ClusterError, ResponseError):
127 """
128 Error indicated CLUSTERDOWN error received from cluster.
129 By default Redis Cluster nodes stop accepting queries if they detect there
130 is at least a hash slot uncovered (no available node is serving it).
131 This way if the cluster is partially down (for example a range of hash
132 slots are no longer covered) the entire cluster eventually becomes
133 unavailable. It automatically returns available as soon as all the slots
134 are covered again.
135 """
137 def __init__(self, resp):
138 self.args = (resp,)
139 self.message = resp
142class AskError(ResponseError):
143 """
144 Error indicated ASK error received from cluster.
145 When a slot is set as MIGRATING, the node will accept all queries that
146 pertain to this hash slot, but only if the key in question exists,
147 otherwise the query is forwarded using a -ASK redirection to the node that
148 is target of the migration.
150 src node: MIGRATING to dst node
151 get > ASK error
152 ask dst node > ASKING command
153 dst node: IMPORTING from src node
154 asking command only affects next command
155 any op will be allowed after asking command
156 """
158 def __init__(self, resp):
159 """should only redirect to master node"""
160 self.args = (resp,)
161 self.message = resp
162 slot_id, new_node = resp.split(" ")
163 host, port = new_node.rsplit(":", 1)
164 self.slot_id = int(slot_id)
165 self.node_addr = self.host, self.port = host, int(port)
168class TryAgainError(ResponseError):
169 """
170 Error indicated TRYAGAIN error received from cluster.
171 Operations on keys that don't exist or are - during resharding - split
172 between the source and destination nodes, will generate a -TRYAGAIN error.
173 """
175 def __init__(self, *args, **kwargs):
176 pass
179class ClusterCrossSlotError(ResponseError):
180 """
181 Error indicated CROSSSLOT error received from cluster.
182 A CROSSSLOT error is generated when keys in a request don't hash to the
183 same slot.
184 """
186 message = "Keys in request don't hash to the same slot"
189class MovedError(AskError):
190 """
191 Error indicated MOVED error received from cluster.
192 A request sent to a node that doesn't serve this key will be replayed with
193 a MOVED error that points to the correct node.
194 """
196 pass
199class MasterDownError(ClusterDownError):
200 """
201 Error indicated MASTERDOWN error received from cluster.
202 Link with MASTER is down and replica-serve-stale-data is set to 'no'.
203 """
205 pass
208class SlotNotCoveredError(RedisClusterException):
209 """
210 This error only happens in the case where the connection pool will try to
211 fetch what node that is covered by a given slot.
213 If this error is raised the client should drop the current node layout and
214 attempt to reconnect and refresh the node layout again
215 """
217 pass
220class MaxConnectionsError(ConnectionError): ...