Making Async and Timeout callable
authorEd Page <eopage@byu.net>
Fri, 12 Feb 2010 03:31:04 +0000 (21:31 -0600)
committerEd Page <eopage@byu.net>
Fri, 12 Feb 2010 03:31:04 +0000 (21:31 -0600)
src/util/go_utils.py

index 8b72dff..47fb16b 100644 (file)
@@ -74,6 +74,9 @@ class Async(object):
                        gobject.source_remove(self.__idleId)
                        self.__idleId = 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()
        @misc.log_exception(_moduleLogger)
        def _on_once(self):
                self.cancel()
@@ -105,6 +108,9 @@ class Timeout(object):
                        gobject.source_remove(self.__timeoutId)
                        self.__timeoutId = 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()
        @misc.log_exception(_moduleLogger)
        def _on_once(self):
                self.cancel()