mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
Merge pull request #5611 from kdelee/awxkit-better-timeout-error
[awxkit] Raise a more informative error when timeout Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
1c09114abd
@ -4,6 +4,7 @@ import json
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from awxkit.utils import poll_until
|
from awxkit.utils import poll_until
|
||||||
|
from awxkit.exceptions import WaitUntilTimeout
|
||||||
|
|
||||||
|
|
||||||
def bytes_to_str(obj):
|
def bytes_to_str(obj):
|
||||||
@ -28,7 +29,11 @@ class HasStatus(object):
|
|||||||
|
|
||||||
def wait_until_status(self, status, interval=1, timeout=60, **kwargs):
|
def wait_until_status(self, status, interval=1, timeout=60, **kwargs):
|
||||||
status = [status] if not isinstance(status, (list, tuple)) else status
|
status = [status] if not isinstance(status, (list, tuple)) else status
|
||||||
|
try:
|
||||||
poll_until(lambda: getattr(self.get(), 'status') in status, interval=interval, timeout=timeout, **kwargs)
|
poll_until(lambda: getattr(self.get(), 'status') in status, interval=interval, timeout=timeout, **kwargs)
|
||||||
|
except WaitUntilTimeout:
|
||||||
|
# This will raise a more informative error than just "WaitUntilTimeout" error
|
||||||
|
self.assert_status(status)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def wait_until_completed(self, interval=5, timeout=60, **kwargs):
|
def wait_until_completed(self, interval=5, timeout=60, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user