comparison sat/memory/disco.py @ 2768:cb34af35af6f

core (disco): client.disco.requestInfo failure are re-raised: so far, requestInfo failure where logged as a warning, and an empty disco was returned. This prevented the requesting entity to know about the error, so now the error is logged and re-raised. CancelError are converted to TimeoutError (requestInfo is only cancelled on timeout). An empty disco is still cached in case of failure, to avoid re-waiting for the entity on next request.
author Goffi <goffi@goffi.org>
date Fri, 11 Jan 2019 19:48:20 +0100
parents 378188abe941
children 003b8b4b56a7
comparison
equal deleted inserted replaced
2767:a97c43dc4924 2768:cb34af35af6f
187 return disco_infos 187 return disco_infos
188 188
189 def infosEb(fail): 189 def infosEb(fail):
190 if fail.check(defer.CancelledError): 190 if fail.check(defer.CancelledError):
191 reason = u"request time-out" 191 reason = u"request time-out"
192 fail = failure.Failure(exceptions.TimeOutError(fail.message))
192 else: 193 else:
193 try: 194 try:
194 reason = unicode(fail.value) 195 reason = unicode(fail.value)
195 except AttributeError: 196 except AttributeError:
196 reason = unicode(fail) 197 reason = unicode(fail)
197 log.warning( 198
198 u"Error while requesting disco infos from {jid}: {reason}".format( 199 log.warning(
199 jid=jid_.full(), reason=reason 200 u"Error while requesting disco infos from {jid}: {reason}".format(
200 ) 201 jid=jid_.full(), reason=reason
201 ) 202 )
203 )
204
205 # XXX we set empty disco in cache, to avoid getting an error or waiting
206 # for a timeout again the next time
202 self.host.memory.updateEntityData( 207 self.host.memory.updateEntityData(
203 jid_, C.ENTITY_CAP_HASH, CAP_HASH_ERROR, profile_key=client.profile 208 jid_, C.ENTITY_CAP_HASH, CAP_HASH_ERROR, profile_key=client.profile
204 ) 209 )
205 disco_infos = self.hashes[CAP_HASH_ERROR] 210 raise fail
206 return disco_infos
207 211
208 d = client.disco.requestInfo(jid_, nodeIdentifier=node) 212 d = client.disco.requestInfo(jid_, nodeIdentifier=node)
209 d.addCallback(infosCb) 213 d.addCallback(infosCb)
210 d.addErrback(infosEb) 214 d.addErrback(infosEb)
211 return d 215 return d