Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit eba1c3a

Browse files
authored
Handle exceptions in polling task (#14)
* Don't stop polling when there is an exception * fix log message * fix linter error
1 parent e02e0c4 commit eba1c3a

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

eppo_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from eppo_client.http_client import HttpClient, SdkParams
1111
from eppo_client.read_write_lock import ReadWriteLock
1212

13-
__version__ = "1.1.0"
13+
__version__ = "1.1.1"
1414

1515
__client: Optional[EppoClient] = None
1616
__lock = ReadWriteLock()

eppo_client/configuration_requestor.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Any, Dict, List, Optional, cast
33
from eppo_client.base_model import SdkBaseModel
44
from eppo_client.configuration_store import ConfigurationStore
5-
from eppo_client.http_client import HttpClient, HttpRequestError
5+
from eppo_client.http_client import HttpClient
66
from eppo_client.rules import Rule
77

88
from eppo_client.shard import ShardRange
@@ -56,9 +56,6 @@ def fetch_and_store_configurations(self) -> Dict[str, ExperimentConfigurationDto
5656
configs[exp_key] = ExperimentConfigurationDto(**exp_config)
5757
self.__config_store.set_configurations(configs)
5858
return configs
59-
except HttpRequestError as e:
59+
except Exception as e:
6060
logger.error("Error retrieving assignment configurations: " + str(e))
61-
if e.is_recoverable():
62-
return {}
63-
else:
64-
raise e # caught by the polling task; causes assignment polling to stop
61+
return {}

eppo_client/http_client.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ def __init__(self, message: str, status_code: int):
2020
self.status_code = status_code
2121
super().__init__(message)
2222

23-
def is_recoverable(self) -> bool:
24-
if self.status_code >= 400 and self.status_code < 500:
25-
return (
26-
self.status_code == HTTPStatus.TOO_MANY_REQUESTS
27-
or self.status_code == HTTPStatus.REQUEST_TIMEOUT
28-
)
29-
return True
30-
3123

3224
REQUEST_TIMEOUT_SECONDS = 2
3325
# Retry reference: https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#module-urllib3.util.retry

0 commit comments

Comments
 (0)