Try a few times before raising the error

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-09-22 15:27:41 +01:00 committed by Pedro Algarvio
parent b44f80163a
commit 686f1d2fa9

View file

@ -165,11 +165,21 @@ def test_pub_server_channel(
req_server_channel.post_fork(handle_payload, io_loop=io_loop)
if master_config["transport"] == "zeromq":
p = Path(str(master_config["sock_dir"])) / "workers.ipc"
mode = os.lstat(p).st_mode
assert bool(os.lstat(p).st_mode & stat.S_IRUSR)
assert not bool(os.lstat(p).st_mode & stat.S_IRGRP)
assert not bool(os.lstat(p).st_mode & stat.S_IROTH)
time.sleep(1)
attempts = 5
while True:
try:
p = Path(str(master_config["sock_dir"])) / "workers.ipc"
mode = os.lstat(p).st_mode
assert bool(os.lstat(p).st_mode & stat.S_IRUSR)
assert not bool(os.lstat(p).st_mode & stat.S_IRGRP)
assert not bool(os.lstat(p).st_mode & stat.S_IROTH)
break
except FileNotFoundError as exc:
if not attempts:
raise exc from None
attempts -= 1
time.sleep(2.5)
pub_channel = salt.channel.client.AsyncPubChannel.factory(minion_config)
received = []