aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/util.py13
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