Mercurial > libervia-backend
changeset 1189:7d640c303140
core (disco): added a timeout to get items
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 08 Sep 2014 21:23:21 +0200 (2014-09-08) |
parents | bf2927e6a0f5 |
children | d8cdbbb244a8 |
files | src/core/sat_main.py src/memory/disco.py |
diffstat | 2 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/sat_main.py Mon Sep 08 21:23:21 2014 +0200 +++ b/src/core/sat_main.py Mon Sep 08 21:23:21 2014 +0200 @@ -288,7 +288,8 @@ log.error("error (plugin %(name)s): %(failure)s" % {'name': plugin_conn_cb[idx][0], 'failure': result}) - yield list_d.addCallback(logPluginResults) + yield list_d.addCallback(logPluginResults) # FIXME: we should have a timeout here, and a way to know if a plugin freeze + # TODO: mesure time to launch of each plugin def _authenticateProfile(self, password, profile): """Authenticate the profile.
--- a/src/memory/disco.py Mon Sep 08 21:23:21 2014 +0200 +++ b/src/memory/disco.py Mon Sep 08 21:23:21 2014 +0200 @@ -24,6 +24,7 @@ from twisted.words.protocols.jabber import jid from twisted.words.protocols.jabber.error import StanzaError from twisted.internet import defer +from twisted.internet import reactor from sat.core.constants import Const as C from wokkel import disco from base64 import b64encode @@ -33,6 +34,7 @@ PRESENCE = '/presence' NS_ENTITY_CAPABILITY = 'http://jabber.org/protocol/caps' CAPABILITY_UPDATE = PRESENCE + '/c[@xmlns="' + NS_ENTITY_CAPABILITY + '"]' +TIMEOUT = 15 class HashGenerationError(Exception): pass @@ -169,6 +171,7 @@ d = self.getItems(jid_, profile_key) d.addCallback(gotItems) d.addCallback(lambda dummy: found_entities) + reactor.callLater(TIMEOUT, d.cancel) # FIXME: one bad service make a general timeout return d def findFeaturesSet(self, features, category=None, type_=None, jid_=None, profile_key=C.PROF_KEY_NONE): @@ -213,6 +216,7 @@ d = self.getItems(jid_, profile_key) d.addCallback(gotItems) d.addCallback(lambda dummy: found_entities) + reactor.callLater(TIMEOUT, d.cancel) # FIXME: one bad service make a general timeout return d def generateHash(self, services):