@@ -212,15 +212,24 @@ def set_update_interval(self, update_interval):
212212 Args:
213213 update_interval: Time in seconds after which to update datafile.
214214 """
215- self .update_interval = update_interval or enums .ConfigManager .DEFAULT_UPDATE_INTERVAL
215+ if not update_interval :
216+ update_interval = enums .ConfigManager .DEFAULT_UPDATE_INTERVAL
217+ self .logger .debug ('Set config update interval to default value {}.' .format (update_interval ))
218+
219+ if not isinstance (update_interval , (int , float )):
220+ raise optimizely_exceptions .InvalidInputException (
221+ 'Invalid update_interval "{}" provided.' .format (update_interval )
222+ )
216223
217224 # If polling interval is less than minimum allowed interval then set it to default update interval.
218- if self . update_interval < enums .ConfigManager .MIN_UPDATE_INTERVAL :
219- self .logger .debug ('Invalid update_interval {} provided . Defaulting to {}' .format (
225+ if update_interval < enums .ConfigManager .MIN_UPDATE_INTERVAL :
226+ self .logger .debug ('update_interval value {} too small . Defaulting to {}' .format (
220227 update_interval ,
221228 enums .ConfigManager .DEFAULT_UPDATE_INTERVAL )
222229 )
223- self .update_interval = enums .ConfigManager .DEFAULT_UPDATE_INTERVAL
230+ update_interval = enums .ConfigManager .DEFAULT_UPDATE_INTERVAL
231+
232+ self .update_interval = update_interval
224233
225234 def set_last_modified (self , response_headers ):
226235 """ Looks up and sets last modified time based on Last-Modified header in the response.
@@ -269,9 +278,14 @@ def is_running(self):
269278
270279 def _run (self ):
271280 """ Triggered as part of the thread which fetches the datafile and sleeps until next update interval. """
272- while self .is_running :
273- self .fetch_datafile ()
274- time .sleep (self .update_interval )
281+ try :
282+ while self .is_running :
283+ self .fetch_datafile ()
284+ time .sleep (self .update_interval )
285+ except (OSError , OverflowError ) as err :
286+ self .logger .error ('Error in time.sleep. '
287+ 'Provided update_interval value may be too big. Error: {}' .format (str (err )))
288+ raise
275289
276290 def start (self ):
277291 """ Start the config manager and the thread to periodically fetch datafile. """
0 commit comments