only calculate delay if enabled
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user