Fixing lots of minor bugs found by lint
[theonering] / src / util / go_utils.py
index 8b72dff..e8fde8b 100644 (file)
@@ -69,11 +69,17 @@ class Async(object):
                else:
                        self.__idleId = gobject.idle_add(self.__func)
 
+       def is_running(self):
+               return self.__idleId is not None
+
        def cancel(self):
                if self.__idleId is not None:
                        gobject.source_remove(self.__idleId)
                        self.__idleId = None
 
+       def __call__(self):
+               return self.start()
+
        @misc.log_exception(_moduleLogger)
        def _on_once(self):
                self.cancel()
@@ -100,11 +106,17 @@ class Timeout(object):
                else:
                        timeout_add_seconds(timeoutInSeconds, self._on_once)
 
+       def is_running(self):
+               return self.__timeoutId is not None
+
        def cancel(self):
                if self.__timeoutId is not None:
                        gobject.source_remove(self.__timeoutId)
                        self.__timeoutId = None
 
+       def __call__(self, **kwds):
+               return self.start(**kwds)
+
        @misc.log_exception(_moduleLogger)
        def _on_once(self):
                self.cancel()