Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ekouts committed Jan 8, 2025
1 parent ffae0ec commit eb01cde
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions reframe/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: BSD-3-Clause

import abc
import itertools
import logging
import logging.handlers
import numbers
Expand Down Expand Up @@ -688,20 +689,21 @@ def emit(self, record):
return

try:
sleep_times = itertools.cycle([.1, .2, .4, .8, 1.6, 3.2])
while True:
response = requests.post(
self._url, data=json_record,
headers=self._headers
)
if response.status_code == 200:
if response.ok:
break

if response.status_code == 429:
time.sleep(1)
time.sleep(next(sleep_times))
continue

raise LoggingError(
f'logging failed: HTTP response code '
f'HTTPJSONhandler logging failed: HTTP response code '
f'{response.status_code}'
)
except requests.exceptions.RequestException as e:
Expand Down

0 comments on commit eb01cde

Please sign in to comment.