From f0727f83beea2f5533631d3d0e52871c4cf73d43 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 13 Jul 2021 06:50:31 -0500 Subject: T3663: use inotify-based watching in "show vrrp". --- python/vyos/ifconfig/vrrp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/vyos/ifconfig/vrrp.py b/python/vyos/ifconfig/vrrp.py index d3e9d5df2..4259060a2 100644 --- a/python/vyos/ifconfig/vrrp.py +++ b/python/vyos/ifconfig/vrrp.py @@ -93,10 +93,14 @@ class VRRP(object): # send signal to generate the configuration file pid = util.read_file(cls.location['pid']) os.kill(int(pid), cls._signal[what]) + util.wait_for_file_write_complete(vyos.keepalived.json_file, + pre_hook=(lambda: os.kill(int(pid), cls._signal[what])), + timeout=30) - # should look for file size change? - sleep(0.2) return util.read_file(fname) + except OSError: + # raised by vyos.util.read_file + raise VRRPNoData("VRRP data is not available (wait time exceeded)") except FileNotFoundError: raise VRRPNoData("VRRP data is not available (process not running or no active groups)") except Exception: -- cgit v1.2.3