summaryrefslogtreecommitdiffstats
path: root/yt/python
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2024-08-28 10:13:37 +0300
committerrobot-piglet <[email protected]>2024-08-28 10:56:21 +0300
commit5d69584883acf76288028d9eda6f5154bad71f03 (patch)
treeb4497ba6497373d6b65846161ff807c653231db7 /yt/python
parentb6ed4760624656bf72a40cf703fadf564d5a5a37 (diff)
Intermediate changes
Diffstat (limited to 'yt/python')
-rw-r--r--yt/python/yt/common.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/yt/python/yt/common.py b/yt/python/yt/common.py
index e2c96a80ff5..a3c2969125f 100644
--- a/yt/python/yt/common.py
+++ b/yt/python/yt/common.py
@@ -834,30 +834,34 @@ def wait(predicate, error_message=None, iter=None, sleep_backoff=None, timeout=N
if sleep_backoff is None:
sleep_backoff = 0.3
+ last_exception = None
if ignore_exceptions:
def check_predicate():
try:
- return predicate()
+ return predicate(), None
# Do not catch BaseException because pytest exceptions are inherited from it
# pytest.fail raises exception inherited from BaseException.
- except Exception:
- return False
+ except Exception as ex:
+ return False, ex
else:
- check_predicate = predicate
+ def check_predicate():
+ return predicate(), None
if timeout is None:
if iter is None:
iter = 100
index = 0
while index < iter:
- if check_predicate():
+ result, last_exception = check_predicate()
+ if result:
return
index += 1
time.sleep(sleep_backoff)
else:
start_time = datetime.datetime.now()
while datetime.datetime.now() - start_time < datetime.timedelta(seconds=timeout):
- if check_predicate():
+ result, last_exception = check_predicate()
+ if result:
return
time.sleep(sleep_backoff)
@@ -865,5 +869,9 @@ def wait(predicate, error_message=None, iter=None, sleep_backoff=None, timeout=N
error_message = error_message()
if error_message is None:
error_message = "Wait failed"
- error_message += " (timeout = {0})".format(timeout if timeout is not None else iter * sleep_backoff)
+
+ error_message += f" (timeout = {timeout if timeout is not None else iter * sleep_backoff}"
+ if last_exception is not None:
+ error_message += f", exception = {last_exception}"
+ error_message += ")"
raise WaitFailed(error_message)