##// END OF EJS Templates
tests: allow logging exceptions on url reach check
super-admin -
r5023:5d32bc46 default
parent child Browse files
Show More
@@ -397,20 +397,21 b' def wait_for_url(url, timeout=10):'
397 397
398 398 while timeout > last:
399 399 last = time.time()
400 if is_url_reachable(url):
400 if is_url_reachable(url, log_exc=False):
401 401 break
402 402 elif (last + wait) > time.time():
403 403 # Go to sleep because not enough time has passed since last check.
404 404 time.sleep(wait)
405 405 else:
406 pytest.fail("Timeout while waiting for URL {}".format(url))
406 pytest.fail(f"Timeout while waiting for URL {url}")
407 407
408 408
409 def is_url_reachable(url):
409 def is_url_reachable(url: str, log_exc: bool = True) -> bool:
410 410 try:
411 411 urllib.request.urlopen(url)
412 412 except urllib.error.URLError:
413 log.exception('URL `{}` reach error'.format(url))
413 if log_exc:
414 log.exception('URL `{}` reach error'.format(url))
414 415 return False
415 416 return True
416 417
General Comments 0
You need to be logged in to leave comments. Login now