Skip to content

Commit 0f7ddc3

Browse files
authored
Merge pull request #21 from IBM/prajwal-jarali-202411150459
Maximum recursion depth error Fix
2 parents 7a97680 + d7dffa1 commit 0f7ddc3

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2024-10-17T11:22:30Z",
6+
"generated_at": "2024-11-15T05:01:17Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

ibm_appconfiguration/configurations/configuration_handler.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
from .internal.utils.url_builder import URLBuilder
3333
from .internal.utils.connectivity import Connectivity
3434
from .internal.utils.api_manager import APIManager
35+
import sys
36+
from time import sleep
37+
38+
# Server max time out is assumed to be 1 week = 604800 seconds = 40320*15
39+
sys.setrecursionlimit(40320)
40+
41+
# delay between each web socket connection retry
42+
delay = 15
3543

3644

3745
class ConfigurationHandler:
@@ -62,7 +70,7 @@ def __init__(self):
6270
self.__segment_map = dict()
6371
self.__live_config_update_enabled = True
6472
ConfigurationHandler.__instance = self
65-
self.__retry_interval = 600
73+
self.__retry_interval = 120
6674
self.__bootstrap_file = None
6775
self.__persistent_cache_dir = None
6876
self.__persistent_data = None
@@ -510,15 +518,15 @@ def __fetch_from_api(self):
510518
Logger.error(f'error while while fetching {exception}')
511519
else:
512520
Logger.error(response.get_result())
513-
if status_code is None:
521+
if status_code is None or status_code == 499:
514522
"""
515523
status_code will be None in-case of
516524
517525
1. request was retried for [429, 500, 502, 503, 504] status codes which has exceeded the retry count and has raised the exception "requests.exceptions.RetryError".
518526
Check api_manager.py for more info.
519527
2. request failed due to unknown "Exception".
520528
"""
521-
Logger.info(config_messages.RETRY_AFTER_TEN_MINUTES)
529+
Logger.info(config_messages.RETRY_AFTER_TWO_MINUTES)
522530
timer = Timer(self.__retry_interval, self.__fetch_from_api)
523531
timer.daemon = True
524532
timer.start()
@@ -534,12 +542,14 @@ def __on_web_socket_callback(self, message=None, error_state=None,
534542
Logger.debug(f'Received message from socket. {message}')
535543
elif error_state:
536544
Logger.error(f'Received error from socket. {error_state}')
545+
self.__on_socket_retry = True
546+
sleep(delay)
537547
self.__start_web_socket()
538548
elif closed_state:
539549
Logger.error('Received close connection from socket.')
540-
if self.__socket is not None:
541-
self.__on_socket_retry = True
542-
self.__start_web_socket()
550+
self.__on_socket_retry = True
551+
sleep(delay)
552+
self.__start_web_socket()
543553
elif open_state:
544554
if self.__on_socket_retry:
545555
self.__on_socket_retry = False

ibm_appconfiguration/configurations/internal/common/config_messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@
3838
NO_INTERNET_CONNECTION_ERROR = 'No connection to internet. Please re-connect.'
3939
PROPERTY_INVALID = "Invalid property_id - "
4040
CONFIGURATIONS_FETCH_SUCCESS = "Successfully fetched the configurations."
41-
RETRY_AFTER_TEN_MINUTES = "Failed to fetch the configurations. Retrying after 10 minutes."
41+
RETRY_AFTER_TWO_MINUTES = "Failed to fetch the configurations. Retrying after 2 minutes."
4242
INPUT_PARAMETER_NOT_BOOLEAN = "Input parameter passed to use_private_endpoint() method is not boolean. Default value will be used."

ibm_appconfiguration/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
"""
1616
Version of ibm-appconfiguration-python-sdk
1717
"""
18-
__version__ = '0.3.4'
18+
__version__ = '0.3.6'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from setuptools import setup, find_packages
1313

1414
NAME = "ibm-appconfiguration-python-sdk"
15-
VERSION = "0.3.5"
15+
VERSION = "0.3.6"
1616
# To install the library, run the following
1717
#
1818
# python setup.py install

0 commit comments

Comments
 (0)