mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #7374 from hfinucane/wait_for_pipes
Allow wait_for to wait on non-traditional files
This commit is contained in:
commit
70abc6f6de
1 changed files with 23 additions and 14 deletions
|
@ -177,20 +177,29 @@ def main():
|
||||||
while datetime.datetime.now() < end:
|
while datetime.datetime.now() < end:
|
||||||
if path:
|
if path:
|
||||||
try:
|
try:
|
||||||
f = open(path)
|
os.stat(path)
|
||||||
try:
|
if search_regex:
|
||||||
if search_regex:
|
try:
|
||||||
if re.search(search_regex, f.read(), re.MULTILINE):
|
f = open(path)
|
||||||
break
|
try:
|
||||||
else:
|
if re.search(search_regex, f.read(), re.MULTILINE):
|
||||||
time.sleep(1)
|
break
|
||||||
else:
|
else:
|
||||||
break
|
time.sleep(1)
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
except OSError, e:
|
||||||
|
# File not present
|
||||||
|
if os.errno == 2:
|
||||||
|
time.sleep(1)
|
||||||
|
else:
|
||||||
|
elapsed = datetime.datetime.now() - start
|
||||||
|
module.fail_json(msg="Failed to stat %s, %s" % (path, e.strerror), elapsed=elapsed.seconds)
|
||||||
elif port:
|
elif port:
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.settimeout(connect_timeout)
|
s.settimeout(connect_timeout)
|
||||||
|
|
Loading…
Reference in a new issue