@@ -1946,8 +1946,11 @@ def _call_thrustcurve_api(name: str, no_cache: bool = False): # pylint: disable
19461946 ------
19471947 ValueError
19481948 If no motor is found or if the downloaded .eng data is missing.
1949+ requests.exceptions.Timeout
1950+ If a search or download request to the ThrustCurve API exceeds the
1951+ timeout limit (5 s connect / 30 s read).
19491952 requests.exceptions.RequestException
1950- If a network or HTTP error occurs during the API call.
1953+ If any other network or HTTP error occurs during the API call.
19511954
19521955 Notes
19531956 -----
@@ -1973,8 +1976,13 @@ def _call_thrustcurve_api(name: str, no_cache: bool = False): # pylint: disable
19731976 )
19741977
19751978 base_url = "https://www.thrustcurve.org/api/v1"
1979+ _timeout = (5 , 30 ) # (connect timeout, read timeout) in seconds
19761980 # Step 1. Search motor
1977- response = requests .get (f"{ base_url } /search.json" , params = {"commonName" : name })
1981+ response = requests .get (
1982+ f"{ base_url } /search.json" ,
1983+ params = {"commonName" : name },
1984+ timeout = _timeout ,
1985+ )
19781986 response .raise_for_status ()
19791987 data = response .json ()
19801988
@@ -1994,6 +2002,7 @@ def _call_thrustcurve_api(name: str, no_cache: bool = False): # pylint: disable
19942002 dl_response = requests .get (
19952003 f"{ base_url } /download.json" ,
19962004 params = {"motorIds" : motor_id , "format" : "RASP" , "data" : "file" },
2005+ timeout = _timeout ,
19972006 )
19982007 dl_response .raise_for_status ()
19992008 dl_data = dl_response .json ()
0 commit comments