diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-02-28 18:54:17 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-02-28 18:54:17 +0100 |
commit | 4eac18a90a7597b0a1fcc100824a42373eaaca72 (patch) | |
tree | 761089bc02b3888d349bb06578ec09a02f1aaeac /src/util.py | |
parent | add deps list (diff) | |
download | xpybar-4eac18a90a7597b0a1fcc100824a42373eaaca72.tar.gz xpybar-4eac18a90a7597b0a1fcc100824a42373eaaca72.tar.bz2 xpybar-4eac18a90a7597b0a1fcc100824a42373eaaca72.tar.xz |
add watch
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/util.py')
-rw-r--r-- | src/util.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util.py b/src/util.py index 936538d..d12d3b2 100644 --- a/src/util.py +++ b/src/util.py @@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' import sys +import time import threading import subprocess @@ -35,6 +36,18 @@ def async(target, name = None, group = None): return t +def watch(interval, target): + ''' + Run a function periodically forever + + @param interval:float The number of seconds to sleep between invocatons + @param target:()→void The function + ''' + while True: + target() + time.sleep(interval) + + def spawn(*command): ''' Spawn an external process |