From 5d9e19a8921dc187a88a43d4e5407a289b32bc06 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 16 May 2007 05:03:55 +0000 Subject: Retry getting buddy properties a few times --- (limited to 'services/presence') diff --git a/services/presence/server_plugin.py b/services/presence/server_plugin.py index d4b7375..cd03c01 100644 --- a/services/presence/server_plugin.py +++ b/services/presence/server_plugin.py @@ -689,11 +689,22 @@ class ServerPlugin(gobject.GObject): self._conn[CONN_INTERFACE_ALIASING].RequestAliases([handle], reply_handler=lambda *args: self._contact_online_aliases_cb(handle, props, *args), error_handler=lambda *args: self._contact_online_aliases_error_cb(handle, props, True, *args)) - - def _contact_online_properties_error_cb(self, handle, err): - """Handle error retrieving property-set for a user (handle)""" - logging.debug("Handle %s - Error getting properties: %s" % (handle, err)) - self._contact_offline(handle) + + def _contact_online_request_properties(self, handle, tries): + self._conn[CONN_INTERFACE_BUDDY_INFO].GetProperties(handle, + reply_handler=lambda *args: self._contact_online_properties_cb(handle, *args), + error_handler=lambda *args: self._contact_online_properties_error_cb(handle, tries, *args)) + return False + + def _contact_online_properties_error_cb(self, handle, tries, err): + """Handle error retrieving property-set for a user (handle)""" + if tries <= 3: + logging.debug("Handle %s - Error getting properties (will retry): %s" % (handle, err)) + tries += 1 + gobject.timeout_add(1000, self._contact_online_request_properties, handle, tries) + else: + logging.debug("Handle %s - Error getting properties: %s" % (handle, err)) + self._contact_offline(handle) def _contact_online(self, handle): """Handle a contact coming online""" @@ -705,9 +716,7 @@ class ServerPlugin(gobject.GObject): # are handled locally return - self._conn[CONN_INTERFACE_BUDDY_INFO].GetProperties(handle, - reply_handler=lambda *args: self._contact_online_properties_cb(handle, *args), - error_handler=lambda *args: self._contact_online_properties_error_cb(handle, *args)) + self._contact_online_request_properties(handle, 1) def _presence_update_cb(self, presence): """Send update for online/offline status of presence""" -- cgit v0.9.1