From d2e7cf2171bb1e44287f16267d7a0588a11c5d72 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 28 Feb 2014 22:11:48 +0100 Subject: add delay parameter to watch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/util.py b/src/util.py index e95c419..d819101 100644 --- a/src/util.py +++ b/src/util.py @@ -36,16 +36,20 @@ def async(target, name = None, group = None): return t -def watch(interval, target): +def watch(interval, target, delay = 0): ''' Run a function periodically forever @param interval:float The number of seconds to sleep between invocatons @param target:()→void The function + @param delay:float Number of extra seconds seconds to wait the first time ''' + target() + if not delay == 0: + time.sleep(delay) while True: - target() time.sleep(interval) + target() def spawn(*command): -- cgit v1.2.3-70-g09d2