1313from apscheduler .triggers .interval import IntervalTrigger
1414
1515from UnleashClient .api import register_client
16- from UnleashClient .constants import DISABLED_VARIATION , ETAG , METRIC_LAST_SENT_TIME
16+ from UnleashClient .constants import (
17+ DISABLED_VARIATION ,
18+ ETAG ,
19+ METRIC_LAST_SENT_TIME ,
20+ REQUEST_RETRIES ,
21+ REQUEST_TIMEOUT ,
22+ )
1723from UnleashClient .events import UnleashEvent , UnleashEventType
1824from UnleashClient .features import Feature
1925from UnleashClient .loader import load_features
@@ -49,6 +55,8 @@ class UnleashClient:
4955 :param environment: Name of the environment using the unleash client, optional & defaults to "default".
5056 :param instance_id: Unique identifier for unleash client instance, optional & defaults to "unleash-client-python"
5157 :param refresh_interval: Provisioning refresh interval in seconds, optional & defaults to 15 seconds
58+ :params request_timeout: Timeout for requests to unleash server in seconds, optional & defaults to 30 seconds
59+ :params request_retries: Number of retries for requests to unleash server, optional & defaults to 3
5260 :param refresh_jitter: Provisioning refresh interval jitter in seconds, optional & defaults to None
5361 :param metrics_interval: Metrics refresh interval in seconds, optional & defaults to 60 seconds
5462 :param metrics_jitter: Metrics refresh interval jitter in seconds, optional & defaults to None
@@ -80,6 +88,8 @@ def __init__(
8088 disable_registration : bool = False ,
8189 custom_headers : Optional [dict ] = None ,
8290 custom_options : Optional [dict ] = None ,
91+ request_timeout : int = REQUEST_TIMEOUT ,
92+ request_retries : int = REQUEST_RETRIES ,
8393 custom_strategies : Optional [dict ] = None ,
8494 cache_directory : Optional [str ] = None ,
8595 project_name : Optional [str ] = None ,
@@ -100,6 +110,8 @@ def __init__(
100110 self .unleash_environment = environment
101111 self .unleash_instance_id = instance_id
102112 self .unleash_refresh_interval = refresh_interval
113+ self .unleash_request_timeout = request_timeout
114+ self .unleash_request_retries = request_retries
103115 self .unleash_refresh_jitter = (
104116 int (refresh_jitter ) if refresh_jitter is not None else None
105117 )
@@ -224,6 +236,7 @@ def initialize_client(self, fetch_toggles: bool = True) -> None:
224236 "custom_options" : self .unleash_custom_options ,
225237 "features" : self .features ,
226238 "cache" : self .cache ,
239+ "request_timeout" : self .unleash_request_timeout ,
227240 }
228241
229242 # Register app
@@ -236,6 +249,7 @@ def initialize_client(self, fetch_toggles: bool = True) -> None:
236249 self .unleash_custom_headers ,
237250 self .unleash_custom_options ,
238251 self .strategy_mapping ,
252+ self .unleash_request_timeout ,
239253 )
240254
241255 if fetch_toggles :
@@ -248,6 +262,8 @@ def initialize_client(self, fetch_toggles: bool = True) -> None:
248262 "cache" : self .cache ,
249263 "features" : self .features ,
250264 "strategy_mapping" : self .strategy_mapping ,
265+ "request_timeout" : self .unleash_request_timeout ,
266+ "request_retries" : self .unleash_request_retries ,
251267 "project" : self .unleash_project_name ,
252268 }
253269 job_func : Callable = fetch_and_load_features
0 commit comments