77import requests
88from .utils import (request , build_portal_params , build_script_params ,
99 filename_from_url , PlaceholderDict )
10- from .const import (PORTAL_PREFIX , FMSErrorCode , API_VERSIONS , API_DATE_FORMATS , API_PATH_PREFIX ,
11- API_PATH )
10+ from .const import (PORTAL_PREFIX , FMSErrorCode , API_VERSIONS ,
11+ API_DATE_FORMATS , API_PATH_PREFIX ,
12+ API_PATH , TIMEOUT )
1213from .exceptions import BadJSON , FileMakerError , RecordError , BadGatewayError
1314from .record import Record
1415from .foundset import Foundset
@@ -45,7 +46,8 @@ def __init__(self, url: str, user: str,
4546 type_conversion : bool = False ,
4647 auto_relogin : bool = False ,
4748 proxies : Optional [Dict ] = None ,
48- api_version : Optional [str ] = None ) -> None :
49+ api_version : Optional [str ] = None ,
50+ timeout : int = TIMEOUT ) -> None :
4951 """Initialize the Server class.
5052
5153 Parameters
@@ -93,6 +95,10 @@ def __init__(self, url: str, user: str,
9395 Configure which version of the data API should be queried (e.g. v1)
9496 It is recommended to set the version explicitly to prevent
9597 potential future breaking changes.
98+ timeout : int
99+ Duration in seconds to wait for FMS to respond (HTTP timeout).
100+ This takes priority over the legacy environment variable
101+ "fmrest_timeout".
96102 """
97103
98104 self .url = url
@@ -104,6 +110,7 @@ def __init__(self, url: str, user: str,
104110 self .verify_ssl = verify_ssl
105111 self .auto_relogin = auto_relogin
106112 self .proxies = proxies
113+ self .timeout = timeout
107114
108115 if not api_version :
109116 warnings .warn ('No api_version given. Defaulting to v1.' )
@@ -701,6 +708,7 @@ def fetch_file(self, file_url: str,
701708 url = file_url ,
702709 verify = self .verify_ssl ,
703710 stream = stream ,
711+ timeout = self .timeout ,
704712 proxies = self .proxies )
705713
706714 return (name ,
@@ -920,6 +928,7 @@ def _call_filemaker(self, method: str, path: str,
920928 verify = self .verify_ssl ,
921929 params = params ,
922930 proxies = self .proxies ,
931+ timeout = self .timeout ,
923932 ** kwargs )
924933
925934 if response .status_code == 502 :
0 commit comments