Skip to content

Commit 025606b

Browse files
authored
Merge pull request #126 from splitio/feature/SDKS-485-refreshRateAndLogLevelException
[SDKS-485: [Python] Update featuresRefreshRate to be 5 seconds]
2 parents f5d189c + af400fb commit 025606b

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

splitio/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44

55
class TimeoutException(Exception):
66
pass
7+
8+
9+
class NetworkingException(Exception):
10+
pass

splitio/input_validator.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from splitio.key import Key
1111
from splitio.treatments import CONTROL
1212
from splitio.api import SdkApi
13+
from splitio.exceptions import NetworkingException
1314

1415

1516
_LOGGER = logging.getLogger(__name__)
@@ -404,10 +405,13 @@ def _valid_apikey_type(api_key, sdk_api_base_url):
404405
'since': -1
405406
}
406407
headers = sdk_api._build_headers()
407-
response = requests.get(url, params=params, headers=headers, timeout=sdk_api._timeout)
408-
if response.status_code == requests.codes.forbidden:
409-
return False
410-
return True
408+
try:
409+
response = requests.get(url, params=params, headers=headers, timeout=sdk_api._timeout)
410+
if response.status_code == requests.codes.forbidden:
411+
return False
412+
return True
413+
except requests.exceptions.RequestException:
414+
raise NetworkingException()
411415

412416

413417
def validate_factory_instantiation(apikey, config, sdk_api_base_url):
@@ -432,9 +436,12 @@ def validate_factory_instantiation(apikey, config, sdk_api_base_url):
432436
_LOGGER.error('no ready parameter has been set - incorrect control treatments '
433437
+ 'could be logged')
434438
return False
435-
if not _valid_apikey_type(apikey, sdk_api_base_url):
436-
_LOGGER.error('factory instantiation: you passed a browser type '
437-
+ 'api_key, please grab an api key from the Split '
438-
+ 'console that is of type sdk')
439-
return False
440-
return True
439+
try:
440+
if not _valid_apikey_type(apikey, sdk_api_base_url):
441+
_LOGGER.error('factory instantiation: you passed a browser type '
442+
+ 'api_key, please grab an api key from the Split '
443+
+ 'console that is of type sdk')
444+
return False
445+
return True
446+
except NetworkingException:
447+
_LOGGER.error("Error occured when tried to connect with Split servers")

splitio/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '7.0.1-rc1'
1+
__version__ = '7.0.1-rc2'

0 commit comments

Comments
 (0)