Skip to content

Commit

Permalink
Rename sleep_times to sleep_intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
ekouts committed Jan 15, 2025
1 parent 958372c commit 2b8adff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/config_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1603,9 +1603,9 @@ This handler transmits the whole log record, meaning that all the information wi

.. versionadded:: 4.1

.. py:attribute:: logging.handlers_perflog..httpjson..sleep_times
.. py:attribute:: logging.handlers_perflog..httpjson..sleep_intervals
In the case that the http request gets a response 429 (TOO_MANY_REQUESTS), Reframe will cycle over this list of sleep times until it succeeds, gets a different code or exceeds the timeout (when it is set).
In the case that the http request gets a response 429 (TOO_MANY_REQUESTS), Reframe will cycle over this list of sleep waiting intervals until it gets a different code or exceeds the timeout (when it is set).

.. versionadded:: 4.7.3

Expand Down
12 changes: 6 additions & 6 deletions reframe/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def _create_httpjson_handler(site_config, config_prefix):
json_formatter = site_config.get(f'{config_prefix}/json_formatter')
extra_headers = site_config.get(f'{config_prefix}/extra_headers')
debug = site_config.get(f'{config_prefix}/debug')
sleep_times = site_config.get(f'{config_prefix}/sleep_times')
sleep_intervals = site_config.get(f'{config_prefix}/sleep_intervals')
timeout = site_config.get(f'{config_prefix}/timeout')

parsed_url = urllib.parse.urlparse(url)
Expand Down Expand Up @@ -598,7 +598,7 @@ def _create_httpjson_handler(site_config, config_prefix):
'no data will be sent to the server')

return HTTPJSONHandler(url, extras, ignore_keys, json_formatter,
extra_headers, debug, sleep_times, timeout)
extra_headers, debug, sleep_intervals, timeout)


def _record_to_json(record, extras, ignore_keys):
Expand Down Expand Up @@ -648,7 +648,7 @@ class HTTPJSONHandler(logging.Handler):

def __init__(self, url, extras=None, ignore_keys=None,
json_formatter=None, extra_headers=None,
debug=False, sleep_times=[.1, .2, .4, .8, 1.6, 3.2],
debug=False, sleep_intervals=[.1, .2, .4, .8, 1.6, 3.2],
timeout=0):
super().__init__()
self._url = url
Expand All @@ -674,7 +674,7 @@ def __init__(self, url, extras=None, ignore_keys=None,

self._debug = debug
self._timeout = timeout
self._sleep_times = sleep_times
self._sleep_intervals = sleep_intervals

def emit(self, record):
# Convert tags to a list to make them JSON friendly
Expand All @@ -695,7 +695,7 @@ def emit(self, record):

timeout_time = time.time() + self._timeout
try:
sleep_times = itertools.cycle(self._sleep_times)
sleep_intervals = itertools.cycle(self._sleep_intervals)
while True:
response = requests.post(
self._url, data=json_record,
Expand All @@ -711,7 +711,7 @@ def emit(self, record):
time.time() < timeout_time
)
):
time.sleep(next(sleep_times))
time.sleep(next(sleep_intervals))
continue

raise LoggingError(
Expand Down
4 changes: 2 additions & 2 deletions reframe/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"json_formatter": {},
"extra_headers": {"type": "object"},
"debug": {"type": "boolean"},
"sleep_times": {
"sleep_intervals": {
"type": "array",
"items": {"type": "number"}
},
Expand Down Expand Up @@ -637,7 +637,7 @@
"logging/handlers_perflog/httpjson_json_formatter": null,
"logging/handlers_perflog/httpjson_extra_headers": {},
"logging/handlers_perflog/httpjson_debug": false,
"logging/handlers_perflog/httpjson_sleep_times": [0.1, 0.2, 0.4, 0.8, 1.6, 3.2],
"logging/handlers_perflog/httpjson_sleep_intervals": [0.1, 0.2, 0.4, 0.8, 1.6, 3.2],
"logging/handlers_perflog/httpjson_timeout": 0,
"modes/options": [],
"modes/target_systems": ["*"],
Expand Down

0 comments on commit 2b8adff

Please sign in to comment.