Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ use_parentheses=true
multi_line_output=3
include_trailing_comma=true
line_length=79
known_third_party = pytest,requests,requests_futures,setuptools
known_third_party = flag_engine,flask,pytest,requests,requests_futures,responses
14 changes: 8 additions & 6 deletions flagsmith/flagsmith.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def __init__(
environment_key: str,
api_url: str = DEFAULT_API_URL,
custom_headers: typing.Dict[str, typing.Any] = None,
request_timeout: int = None,
enable_client_side_evaluation: bool = False,
request_timeout_seconds: int = None,
enable_local_evaluation: bool = False,
environment_refresh_interval_seconds: int = 60,
retries: Retry = None,
enable_analytics: bool = False,
Expand All @@ -40,15 +40,15 @@ def __init__(
retries = retries or Retry(total=3, backoff_factor=0.1)

self.api_url = api_url if api_url.endswith("/") else f"{api_url}/"
self.request_timeout = request_timeout
self.request_timeout_seconds = request_timeout_seconds
self.session.mount(self.api_url, HTTPAdapter(max_retries=retries))

self.environment_flags_url = f"{self.api_url}flags/"
self.identities_url = f"{self.api_url}identities/"
self.environment_url = f"{self.api_url}environment-document/"

self._environment = None
if enable_client_side_evaluation:
if enable_local_evaluation:
self.environment_data_polling_manager_thread = (
EnvironmentDataPollingManager(
main=self,
Expand All @@ -59,7 +59,7 @@ def __init__(

self._analytics_processor = (
AnalyticsProcessor(
environment_key, self.api_url, timeout=self.request_timeout
environment_key, self.api_url, timeout=self.request_timeout_seconds
)
if enable_analytics
else None
Expand Down Expand Up @@ -151,7 +151,9 @@ def _get_identity_flags_from_api(
def _get_json_response(self, url: str, method: str, body: dict = None):
try:
request_method = getattr(self.session, method.lower())
response = request_method(url, json=body, timeout=self.request_timeout)
response = request_method(
url, json=body, timeout=self.request_timeout_seconds
)
if response.status_code != 200:
raise FlagsmithAPIError(
"Invalid request made to Flagsmith API. Response status code: %d",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_flagsmith.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_flagsmith_starts_polling_manager_on_init_if_enabled(mocker, api_key):
)

# When
Flagsmith(environment_key=api_key, enable_client_side_evaluation=True)
Flagsmith(environment_key=api_key, enable_local_evaluation=True)

# Then
mock_polling_manager.start.assert_called_once()
Expand Down