3
3
import asyncio
4
4
import copy
5
5
import logging
6
+ import time
6
7
from collections .abc import Coroutine , MutableMapping
7
8
from functools import wraps
8
9
from time import sleep
38
39
NodeNotFoundError ,
39
40
ServerNotReachableError ,
40
41
ServerNotResponsiveError ,
42
+ URLNotFoundError ,
41
43
)
42
44
from .graphql import Mutation , Query
43
45
from .node import (
@@ -878,7 +880,8 @@ async def execute_graphql(
878
880
879
881
retry = True
880
882
resp = None
881
- while retry :
883
+ start_time = time .time ()
884
+ while retry and time .time () - start_time < self .config .max_retry_duration :
882
885
retry = self .retry_on_failure
883
886
try :
884
887
resp = await self ._post (url = url , payload = payload , headers = headers , timeout = timeout )
@@ -902,6 +905,8 @@ async def execute_graphql(
902
905
errors = response .get ("errors" , [])
903
906
messages = [error .get ("message" ) for error in errors ]
904
907
raise AuthenticationError (" | " .join (messages )) from exc
908
+ if exc .response .status_code == 404 :
909
+ raise URLNotFoundError (url = url )
905
910
906
911
if not resp :
907
912
raise Error ("Unexpected situation, resp hasn't been initialized." )
@@ -1613,7 +1618,8 @@ def execute_graphql(
1613
1618
1614
1619
retry = True
1615
1620
resp = None
1616
- while retry :
1621
+ start_time = time .time ()
1622
+ while retry and time .time () - start_time < self .config .max_retry_duration :
1617
1623
retry = self .retry_on_failure
1618
1624
try :
1619
1625
resp = self ._post (url = url , payload = payload , headers = headers , timeout = timeout )
@@ -1637,6 +1643,8 @@ def execute_graphql(
1637
1643
errors = response .get ("errors" , [])
1638
1644
messages = [error .get ("message" ) for error in errors ]
1639
1645
raise AuthenticationError (" | " .join (messages )) from exc
1646
+ if exc .response .status_code == 404 :
1647
+ raise URLNotFoundError (url = url )
1640
1648
1641
1649
if not resp :
1642
1650
raise Error ("Unexpected situation, resp hasn't been initialized." )
0 commit comments