aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-28 22:11:48 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-28 22:11:48 +0100
commitd2e7cf2171bb1e44287f16267d7a0588a11c5d72 (patch)
treee8b181f67340dc94731a533937f4c59993e76369
parentadd spawn_read (diff)
downloadxpybar-d2e7cf2171bb1e44287f16267d7a0588a11c5d72.tar.gz
xpybar-d2e7cf2171bb1e44287f16267d7a0588a11c5d72.tar.bz2
xpybar-d2e7cf2171bb1e44287f16267d7a0588a11c5d72.tar.xz
add delay parameter to watch
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/util.py8
1 files changed, 6 insertions, 2 deletions
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):