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

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 ExecAbortError(ResponseError): 

53 pass 

54 

55 

56class ReadOnlyError(ResponseError): 

57 pass 

58 

59 

60class NoPermissionError(ResponseError): 

61 pass 

62 

63 

64class ModuleError(ResponseError): 

65 pass 

66 

67 

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 

73 

74 

75class LockNotOwnedError(LockError): 

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

77 pass 

78 

79 

80class ChildDeadlockedError(Exception): 

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

82 pass 

83 

84 

85class AuthenticationWrongNumberOfArgsError(ResponseError): 

86 """ 

87 An error to indicate that the wrong number of args 

88 were sent to the AUTH command 

89 """ 

90 

91 pass 

92 

93 

94class RedisClusterException(Exception): 

95 """ 

96 Base exception for the RedisCluster client 

97 """ 

98 

99 pass 

100 

101 

102class ClusterError(RedisError): 

103 """ 

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

105 command execution TTL 

106 """ 

107 

108 pass 

109 

110 

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

121 

122 def __init__(self, resp): 

123 self.args = (resp,) 

124 self.message = resp 

125 

126 

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

141 

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) 

150 

151 

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

158 

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

160 pass 

161 

162 

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

169 

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

171 

172 

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

179 

180 pass 

181 

182 

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

188 

189 pass 

190 

191 

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. 

196 

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

200 

201 pass 

202 

203 

204class MaxConnectionsError(ConnectionError): 

205 ...