From db6807710f3f25732b63ec1b50f9604f9ee6a934 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Thu, 8 Dec 2022 14:43:30 +0100 Subject: [PATCH] Fix service timeout GQL handling --- twitch.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/twitch.py b/twitch.py index 24fd47b..fc21501 100644 --- a/twitch.py +++ b/twitch.py @@ -1315,16 +1315,22 @@ class Twitch: response_list = response_json else: response_list = [response_json] + has_timeout: bool = False for response_json in response_list: - if "errors" in response_json and response_json["errors"]: - if ( - "message" in response_json["errors"] - and response_json["errors"]["message"] == "service timeout" - ): - await asyncio.sleep(1) - continue - raise MinerException(f"GQL error: {response_json['errors']}") - return orig_response + if "errors" in response_json: + for error_dict in response_json["errors"]: + if ( + "message" in error_dict["errors"] + and error_dict["errors"]["message"] == "service timeout" + ): + has_timeout = True + break + raise MinerException(f"GQL error: {response_json['errors']}") + if has_timeout: + break + else: + return orig_response + await asyncio.sleep(1) def _merge_data(self, primary_data: JsonType, secondary_data: JsonType) -> JsonType: merged = {}