[pyatspi2] Have calls on the async bus timeout after 2 seconds



commit 17a81062c4e3180bdc8ddd6ec5857a31fc0e75f0
Author: Mike Gorse <mgorse novell com>
Date:   Thu Oct 7 14:42:46 2010 +0200

    Have calls on the async bus timeout after 2 seconds

 pyatspi/accessible.py     |    5 ++++-
 pyatspi/busutils/proxy.py |    8 +++++++-
 pyatspi/cache.py          |    2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/pyatspi/accessible.py b/pyatspi/accessible.py
index d145877..00582c1 100644
--- a/pyatspi/accessible.py
+++ b/pyatspi/accessible.py
@@ -469,7 +469,10 @@ class Accessible(BaseProxy):
                 if self.cached and not(self._cached_data.state[0] & (1 << STATE_MANAGES_DESCENDANTS)):
                         return len(self._cached_data.children)
                 else:
-                        return Int32(self._pgetter(ATSPI_ACCESSIBLE, "ChildCount"))
+                        try:
+                                return Int32(self._pgetter(ATSPI_ACCESSIBLE, "ChildCount"))
+                        except LookupError:
+                                return 0
         _childCountDoc = \
                 """
                 childCount: the number of children contained by this object.
diff --git a/pyatspi/busutils/proxy.py b/pyatspi/busutils/proxy.py
index 9bff254..ebbb72a 100644
--- a/pyatspi/busutils/proxy.py
+++ b/pyatspi/busutils/proxy.py
@@ -100,11 +100,17 @@ class AccessibilityProxy (_connection.ProxyObject):
                                 *iargs,
                                 **ikwargs)
 
+                        def endCall(data):
+                                data.loop.quit()
+                                return False
+
 			self._bus.freezeEvents()
                         if data.event is not None:
                                 data.event.wait()
                         else:
+                                data.timeout_tag = gobject.timeout_add(2000, endCall, data)
 			        data.loop.run ()
+                                gobject.source_remove(data.timeout_tag)
 			AccessibilityProxy._main_loop_pool.put_nowait (data.loop)
 			self._bus.thawEvents()
                         self._bus.registry.releaseLock()
@@ -119,7 +125,7 @@ class AccessibilityProxy (_connection.ProxyObject):
                                 raise data.error
 
 			if data.args == None:
-				raise Exception ("Return arguments not set")
+				raise LookupError
 
                         if len (data.args) == 0:
                                 return None
diff --git a/pyatspi/cache.py b/pyatspi/cache.py
index bf5483d..9052ada 100644
--- a/pyatspi/cache.py
+++ b/pyatspi/cache.py
@@ -243,7 +243,7 @@ class ApplicationCacheManager (object):
                 cache_itf = dbus.Interface (cache_obj, _ATSPI_CACHE_INTERFACE)
                 try:
                         self._add_objects(cache_itf.GetItems())
-                except dbus.exceptions.DBusException:
+                except LookupError, dbus.exceptions.DBusException:
                         pass
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]