used as executable to look up in $PATH.
@type callback: (pid, condition) -> None
@param callback: is executed when the command completes
- @rtype: (int, int)
- @returns: the child process pid and the event id of the callback
+ @rtype: int
+ @returns: the child process pid
"""
ret = GObject.spawn_async(command,
flags=GObject.SPAWN_SEARCH_PATH | GObject.SPAWN_DO_NOT_REAP_CHILD)
pid = ret[0]
assert pid
- watch = GObject.child_watch_add(pid, callback)
- return pid, watch
+ GObject.child_watch_add(pid, callback)
+ return pid
+
+class ScheduledFunction(object):
+ def __init__(self, interval, function):
+ """
+ @type interval: float
+ @param interval: seconds
+ """
+ self.event = GObject.timeout_add(int(1000 * interval), function)
+
+ def cancel(self):
+ ret = GObject.source_remove(self.event)
+ assert ret