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

1"Core exceptions raised by the Redis client" 

2 

3 

4class RedisError(Exception): 

5 pass 

6 

7 

8class ConnectionError(RedisError): 

9 pass 

10 

11 

12class TimeoutError(RedisError): 

13 pass 

14 

15 

16class AuthenticationError(ConnectionError): 

17 pass 

18 

19 

20class AuthorizationError(ConnectionError): 

21 pass 

22 

23 

24class BusyLoadingError(ConnectionError): 

25 pass 

26 

27 

28class InvalidResponse(RedisError): 

29 pass 

30 

31 

32class ResponseError(RedisError): 

33 pass 

34 

35 

36class DataError(RedisError): 

37 pass 

38 

39 

40class PubSubError(RedisError): 

41 pass 

42 

43 

44class WatchError(RedisError): 

45 pass 

46 

47 

48class NoScriptError(ResponseError): 

49 pass 

50 

51 

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 

57 

58 For more information see `Memory optimization in Redis <https://redis.io/docs/management/optimization/memory-optimization/#memory-allocation>`_. # noqa 

59 """ 

60 

61 pass 

62 

63 

64class ExecAbortError(ResponseError): 

65 pass 

66 

67 

68class ReadOnlyError(ResponseError): 

69 pass 

70 

71 

72class NoPermissionError(ResponseError): 

73 pass 

74 

75 

76class ModuleError(ResponseError): 

77 pass 

78 

79 

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. 

84 

85 def __init__(self, message=None, lock_name=None): 

86 self.message = message 

87 self.lock_name = lock_name 

88 

89 

90class LockNotOwnedError(LockError): 

91 "Error trying to extend or release a lock that is (no longer) owned" 

92 pass 

93 

94 

95class ChildDeadlockedError(Exception): 

96 "Error indicating that a child process is deadlocked after a fork()" 

97 pass 

98 

99 

100class AuthenticationWrongNumberOfArgsError(ResponseError): 

101 """ 

102 An error to indicate that the wrong number of args 

103 were sent to the AUTH command 

104 """ 

105 

106 pass 

107 

108 

109class RedisClusterException(Exception): 

110 """ 

111 Base exception for the RedisCluster client 

112 """ 

113 

114 pass 

115 

116 

117class ClusterError(RedisError): 

118 """ 

119 Cluster errors occurred multiple times, resulting in an exhaustion of the 

120 command execution TTL 

121 """ 

122 

123 pass 

124 

125 

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 """ 

136 

137 def __init__(self, resp): 

138 self.args = (resp,) 

139 self.message = resp 

140 

141 

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. 

149 

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 """ 

157 

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) 

166 

167 

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 """ 

174 

175 def __init__(self, *args, **kwargs): 

176 pass 

177 

178 

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 """ 

185 

186 message = "Keys in request don't hash to the same slot" 

187 

188 

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 """ 

195 

196 pass 

197 

198 

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 """ 

204 

205 pass 

206 

207 

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. 

212 

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 """ 

216 

217 pass 

218 

219 

220class MaxConnectionsError(ConnectionError): ...