Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/redis/exceptions.py: 87%
69 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 07:16 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 07: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 ExecAbortError(ResponseError):
53 pass
56class ReadOnlyError(ResponseError):
57 pass
60class NoPermissionError(ResponseError):
61 pass
64class ModuleError(ResponseError):
65 pass
68class LockError(RedisError, ValueError):
69 "Errors acquiring or releasing a lock"
70 # NOTE: For backwards compatibility, this class derives from ValueError.
71 # This was originally chosen to behave like threading.Lock.
72 pass
75class LockNotOwnedError(LockError):
76 "Error trying to extend or release a lock that is (no longer) owned"
77 pass
80class ChildDeadlockedError(Exception):
81 "Error indicating that a child process is deadlocked after a fork()"
82 pass
85class AuthenticationWrongNumberOfArgsError(ResponseError):
86 """
87 An error to indicate that the wrong number of args
88 were sent to the AUTH command
89 """
91 pass
94class RedisClusterException(Exception):
95 """
96 Base exception for the RedisCluster client
97 """
99 pass
102class ClusterError(RedisError):
103 """
104 Cluster errors occurred multiple times, resulting in an exhaustion of the
105 command execution TTL
106 """
108 pass
111class ClusterDownError(ClusterError, ResponseError):
112 """
113 Error indicated CLUSTERDOWN error received from cluster.
114 By default Redis Cluster nodes stop accepting queries if they detect there
115 is at least a hash slot uncovered (no available node is serving it).
116 This way if the cluster is partially down (for example a range of hash
117 slots are no longer covered) the entire cluster eventually becomes
118 unavailable. It automatically returns available as soon as all the slots
119 are covered again.
120 """
122 def __init__(self, resp):
123 self.args = (resp,)
124 self.message = resp
127class AskError(ResponseError):
128 """
129 Error indicated ASK error received from cluster.
130 When a slot is set as MIGRATING, the node will accept all queries that
131 pertain to this hash slot, but only if the key in question exists,
132 otherwise the query is forwarded using a -ASK redirection to the node that
133 is target of the migration.
134 src node: MIGRATING to dst node
135 get > ASK error
136 ask dst node > ASKING command
137 dst node: IMPORTING from src node
138 asking command only affects next command
139 any op will be allowed after asking command
140 """
142 def __init__(self, resp):
143 """should only redirect to master node"""
144 self.args = (resp,)
145 self.message = resp
146 slot_id, new_node = resp.split(" ")
147 host, port = new_node.rsplit(":", 1)
148 self.slot_id = int(slot_id)
149 self.node_addr = self.host, self.port = host, int(port)
152class TryAgainError(ResponseError):
153 """
154 Error indicated TRYAGAIN error received from cluster.
155 Operations on keys that don't exist or are - during resharding - split
156 between the source and destination nodes, will generate a -TRYAGAIN error.
157 """
159 def __init__(self, *args, **kwargs):
160 pass
163class ClusterCrossSlotError(ResponseError):
164 """
165 Error indicated CROSSSLOT error received from cluster.
166 A CROSSSLOT error is generated when keys in a request don't hash to the
167 same slot.
168 """
170 message = "Keys in request don't hash to the same slot"
173class MovedError(AskError):
174 """
175 Error indicated MOVED error received from cluster.
176 A request sent to a node that doesn't serve this key will be replayed with
177 a MOVED error that points to the correct node.
178 """
180 pass
183class MasterDownError(ClusterDownError):
184 """
185 Error indicated MASTERDOWN error received from cluster.
186 Link with MASTER is down and replica-serve-stale-data is set to 'no'.
187 """
189 pass
192class SlotNotCoveredError(RedisClusterException):
193 """
194 This error only happens in the case where the connection pool will try to
195 fetch what node that is covered by a given slot.
197 If this error is raised the client should drop the current node layout and
198 attempt to reconnect and refresh the node layout again
199 """
201 pass
204class MaxConnectionsError(ConnectionError):
205 ...