1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

sleep when only doing a time delay to avoid cpu churn

This commit is contained in:
Brian Coca 2015-05-26 09:57:38 -04:00 committed by Matt Clay
parent e34c7f31dc
commit 7ccc2143fd

View file

@ -337,12 +337,15 @@ def main():
if params['exclude_hosts'] is not None and state != 'drained':
module.fail_json(msg="exclude_hosts should only be with state=drained")
start = datetime.datetime.now()
if delay:
time.sleep(delay)
if state in [ 'stopped', 'absent' ]:
if not port and not path and state != 'drained':
time.sleep(timeout)
elif state in [ 'stopped', 'absent' ]:
### first wait for the stop condition
end = start + datetime.timedelta(seconds=timeout)
@ -365,6 +368,8 @@ def main():
time.sleep(1)
except:
break
else:
time.sleep(1)
else:
elapsed = datetime.datetime.now() - start
if port:
@ -427,6 +432,8 @@ def main():
except:
time.sleep(1)
pass
else:
time.sleep(1)
else:
elapsed = datetime.datetime.now() - start
if port: