33import asyncio
44import copy
55import logging
6+ import time
67from collections .abc import Coroutine , MutableMapping
78from functools import wraps
89from time import sleep
3839 NodeNotFoundError ,
3940 ServerNotReachableError ,
4041 ServerNotResponsiveError ,
42+ URLNotFoundError ,
4143)
4244from .graphql import Mutation , Query
4345from .node import (
@@ -878,7 +880,8 @@ async def execute_graphql(
878880
879881 retry = True
880882 resp = None
881- while retry :
883+ start_time = time .time ()
884+ while retry and time .time () - start_time < self .config .max_retry_duration :
882885 retry = self .retry_on_failure
883886 try :
884887 resp = await self ._post (url = url , payload = payload , headers = headers , timeout = timeout )
@@ -902,6 +905,8 @@ async def execute_graphql(
902905 errors = response .get ("errors" , [])
903906 messages = [error .get ("message" ) for error in errors ]
904907 raise AuthenticationError (" | " .join (messages )) from exc
908+ if exc .response .status_code == 404 :
909+ raise URLNotFoundError (url = url )
905910
906911 if not resp :
907912 raise Error ("Unexpected situation, resp hasn't been initialized." )
@@ -1613,7 +1618,8 @@ def execute_graphql(
16131618
16141619 retry = True
16151620 resp = None
1616- while retry :
1621+ start_time = time .time ()
1622+ while retry and time .time () - start_time < self .config .max_retry_duration :
16171623 retry = self .retry_on_failure
16181624 try :
16191625 resp = self ._post (url = url , payload = payload , headers = headers , timeout = timeout )
@@ -1637,6 +1643,8 @@ def execute_graphql(
16371643 errors = response .get ("errors" , [])
16381644 messages = [error .get ("message" ) for error in errors ]
16391645 raise AuthenticationError (" | " .join (messages )) from exc
1646+ if exc .response .status_code == 404 :
1647+ raise URLNotFoundError (url = url )
16401648
16411649 if not resp :
16421650 raise Error ("Unexpected situation, resp hasn't been initialized." )
0 commit comments