Altering --timeout from awxkit to --action-timeout to remove conflict with new launch timeout

This commit is contained in:
John Westcott IV 2022-09-16 14:10:16 -04:00 committed by Alan Rominger
parent d07177be9c
commit 75597cf29c
No known key found for this signature in database
GPG Key ID: C2D7EAAA12B63559
2 changed files with 7 additions and 7 deletions

View File

@ -50,7 +50,7 @@ class Launchable(object):
if with_pk:
parser.choices[self.action].add_argument('id', type=functools.partial(pk_or_name, None, self.resource, page=self.page), help='')
parser.choices[self.action].add_argument('--monitor', action='store_true', help='If set, prints stdout of the launched job until it finishes.')
parser.choices[self.action].add_argument('--timeout', type=int, help='If set with --monitor or --wait, time out waiting on job completion.') # noqa
parser.choices[self.action].add_argument('--action-timeout', type=int, help='If set with --monitor or --wait, time out waiting on job completion.')
parser.choices[self.action].add_argument('--wait', action='store_true', help='If set, waits until the launched job finishes.')
launch_time_options = self.page.connection.options(self.page.endpoint + '1/{}/'.format(self.action))
@ -66,7 +66,7 @@ class Launchable(object):
response,
self.page.connection.session,
print_stdout=not kwargs.get('wait'),
timeout=kwargs.get('timeout'),
action_timeout=kwargs.get('action_timeout'),
)
if status:
response.json['status'] = status
@ -78,7 +78,7 @@ class Launchable(object):
monitor_kwargs = {
'monitor': kwargs.pop('monitor', False),
'wait': kwargs.pop('wait', False),
'timeout': kwargs.pop('timeout', False),
'action_timeout': kwargs.pop('action_timeout', False),
}
response = self.page.get().related.get(self.action).post(kwargs)
self.monitor(response, **monitor_kwargs)

View File

@ -9,7 +9,7 @@ from .utils import cprint, color_enabled, STATUS_COLORS
from awxkit.utils import to_str
def monitor_workflow(response, session, print_stdout=True, timeout=None, interval=0.25):
def monitor_workflow(response, session, print_stdout=True, action_timeout=None, interval=0.25):
get = response.url.get
payload = {
'order_by': 'finished',
@ -46,7 +46,7 @@ def monitor_workflow(response, session, print_stdout=True, timeout=None, interva
started = time.time()
seen = set()
while True:
if timeout and time.time() - started > timeout:
if action_timeout and time.time() - started > action_timeout:
if print_stdout:
cprint('Monitoring aborted due to timeout.', 'red')
break
@ -68,7 +68,7 @@ def monitor_workflow(response, session, print_stdout=True, timeout=None, interva
return get().json.status
def monitor(response, session, print_stdout=True, timeout=None, interval=0.25):
def monitor(response, session, print_stdout=True, action_timeout=None, interval=0.25):
get = response.url.get
payload = {'order_by': 'start_line', 'no_truncate': True}
if response.type == 'job':
@ -97,7 +97,7 @@ def monitor(response, session, print_stdout=True, timeout=None, interval=0.25):
started = time.time()
while True:
if timeout and time.time() - started > timeout:
if action_timeout and time.time() - started > action_timeout:
if print_stdout:
cprint('Monitoring aborted due to timeout.', 'red')
break