Fix service timeout GQL handling

This commit is contained in:
DevilXD committed 2022-12-08 14:43:30 +01:00
1 parent ca881e56c0
commit db6807710f
1 file changed
+11 -5
+11 -5
View File
@@ -1315,16 +1315,22 @@ class Twitch:
response_list = response_json response_list = response_json
else: else:
response_list = [response_json] response_list = [response_json]
has_timeout: bool = False
for response_json in response_list: for response_json in response_list:
if "errors" in response_json and response_json["errors"]: if "errors" in response_json:
for error_dict in response_json["errors"]:
if ( if (
"message" in response_json["errors"] "message" in error_dict["errors"]
and response_json["errors"]["message"] == "service timeout" and error_dict["errors"]["message"] == "service timeout"
): ):
await asyncio.sleep(1) has_timeout = True
continue break
raise MinerException(f"GQL error: {response_json['errors']}") raise MinerException(f"GQL error: {response_json['errors']}")
if has_timeout:
break
else:
return orig_response return orig_response
await asyncio.sleep(1)
def _merge_data(self, primary_data: JsonType, secondary_data: JsonType) -> JsonType: def _merge_data(self, primary_data: JsonType, secondary_data: JsonType) -> JsonType:
merged = {} merged = {}