Coverage for qreward / globals.py: 100.00%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-23 19:32 +0000

1OVERLOAD_EXCEPTIONS = frozenset( 

2 [ 

3 # 超时异常 - Timeout Exception 

4 "asyncio.TimeoutError", 

5 "concurrent.futures.TimeoutError", 

6 "socket.timeout", 

7 "TimeoutError", 

8 "ReadTimeout", 

9 "ConnectTimeout", 

10 "ConnectionTimeout", 

11 # 连接异常 - Connection Exception 

12 "ConnectionError", 

13 "ConnectionRefusedError", 

14 "ConnectionAbortedError", 

15 "ConnectionResetError", 

16 "BrokenPipeError", 

17 "TooManyRedirects", 

18 # 资源不足异常 - Resource Exhaustion Exception 

19 "MemoryError", 

20 "OSError", 

21 "ResourceExhausted", 

22 # 网络异常 - Network Exception 

23 "SSLError", 

24 "ProtocolError", 

25 "RemoteDisconnected", 

26 "IncompleteRead", 

27 # 其他可能的过载异常 - Other Possible Overload Exception 

28 "RateLimitExceeded", 

29 "ThrottlingException", 

30 ] 

31) 

32 

33# from requests library 

34_REQUESTS_OVERLOAD_EXCEPTIONS = frozenset( 

35 [ 

36 "ConnectTimeout", 

37 "ReadTimeout", 

38 "ConnectionError", 

39 "TooManyRedirects", 

40 "SSLError", 

41 ] 

42) 

43 

44# from urllib3 library 

45_URLLIB3_OVERLOAD_EXCEPTIONS = frozenset( 

46 [ 

47 "TimeoutError", 

48 "TimeoutStateError", 

49 "ReadTimeoutError", 

50 "ConnectTimeoutError", 

51 "ConnectionError", 

52 "NewConnectionError", 

53 ] 

54) 

55 

56# from aiohttp library 

57_AIOHTTP_OVERLOAD_EXCEPTIONS = frozenset( 

58 [ 

59 "TimeoutError", 

60 "ClientError", 

61 "ServerDisconnectedError", 

62 "ClientConnectorError", 

63 "ServerTimeoutError", 

64 ] 

65) 

66 

67# from httpx library 

68_HTTPX_OVERLOAD_EXCEPTIONS = frozenset( 

69 [ 

70 "TimeoutException", 

71 "ConnectTimeout", 

72 "ReadTimeout", 

73 "PoolTimeout", 

74 "NetworkError", 

75 ] 

76) 

77 

78# from grpc library 

79_GRPC_OVERLOAD_EXCEPTIONS = frozenset( 

80 [ 

81 "DeadlineExceeded", 

82 "Unavailable", 

83 "ResourceExhausted", 

84 ] 

85) 

86 

87# 框架级异常判断(library) 

88LIBRARY_OVERLOAD_EXCEPTIONS_MAPPING = { 

89 "requests": _REQUESTS_OVERLOAD_EXCEPTIONS, 

90 "urllib3": _URLLIB3_OVERLOAD_EXCEPTIONS, 

91 "aiohttp": _AIOHTTP_OVERLOAD_EXCEPTIONS, 

92 "httpx": _HTTPX_OVERLOAD_EXCEPTIONS, 

93 "grpc": _GRPC_OVERLOAD_EXCEPTIONS, 

94} 

95 

96# 系统级异常判断(errno) 

97SYSTEM_OVERLOAD_INDICATORS = frozenset( 

98 [ 

99 "errno 24", # EMFILE - Too many open files 

100 "errno 23", # ENFILE - File table overflow 

101 "errno 11", # EAGAIN/EWOULDBLOCK - Resource temporarily 

102 # unavailable 

103 "errno 12", # ENOMEM - Out of memory 

104 "errno 10054", # WSAECONNRESET - Connection reset by peer 

105 # (Windows) 

106 "errno 104", # ECONNRESET - Connection reset by peer (Linux) 

107 "errno 110", # ETIMEDOUT - Connection timed out (Linux) 

108 "errno 10060", # WSAETIMEDOUT - Connection timed out 

109 # (Windows) 

110 ] 

111) 

112 

113# 过载相关关键词 

114OVERLOAD_KEYWORDS = frozenset( 

115 [ 

116 # 资源不足相关 

117 "overload", 

118 "overloaded", 

119 "busy", 

120 "unavailable", 

121 "not available", 

122 "too many", 

123 "exceeded", 

124 "limit", 

125 "quota", 

126 "capacity", 

127 # 超时相关 

128 "timeout", 

129 "time out", 

130 "deadline exceeded", 

131 "timed out", 

132 # 连接相关 

133 "connection refused", 

134 "connection reset", 

135 "broken pipe", 

136 "connection pool", 

137 "pool exhausted", 

138 # 资源相关 

139 "resource", 

140 "memory", 

141 "cpu", 

142 "out of memory", 

143 "out of resources", 

144 "resource temporarily unavailable", 

145 # 服务相关 

146 "service unavailable", 

147 "temporarily unavailable", 

148 "server busy", 

149 "server overload", 

150 "high load", 

151 "traffic spike", 

152 # 负载相关 

153 "load", 

154 "high load", 

155 "traffic", 

156 "request rate", 

157 "rate limit", 

158 "throttled", 

159 "throttle", 

160 "limit", 

161 "limited", 

162 # 系统资源相关 

163 "too many open files", 

164 "file descriptor", 

165 "process limit", 

166 "thread limit", 

167 ] 

168)