only calculate delay if enabled

This commit is contained in:
Peter Bieringer
2026-03-07 16:22:08 +01:00
parent f027647f96
commit 9432e0aeb7

View File

@@ -309,12 +309,13 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
flags_text = ""
# delay on error
if status >= 400:
random_delay = self._delay_on_error * (1 + random.random())
if status >= 500:
random_delay = 2 * random_delay
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Response delay triggered by result code: %d -> %0.3f seconds", status, random_delay)
time.sleep(random_delay)
if self._delay_on_error > 0:
random_delay = self._delay_on_error * (1 + random.random())
if status >= 500:
random_delay = 2 * random_delay
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Response delay triggered by result code: %d -> %0.3f seconds", status, random_delay)
time.sleep(random_delay)
if answer is not None:
logger.info("%s response status for %r%s in %.3f seconds %s %s bytes%s: %s",
request_method, unsafe_path, depthinfo,