fix timeouts in get_availability

This commit is contained in:
Jack 2016-09-30 13:35:13 -04:00
parent 8d961d6ce6
commit 640e000b9f

View file

@ -2597,14 +2597,18 @@ class Daemon(jsonrpc.JSONRPC):
for blob_availability in blob_availabilities: for blob_availability in blob_availabilities:
for blob, peers in blob_availability.iteritems(): for blob, peers in blob_availability.iteritems():
peer_counts.append(peers) peer_counts.append(peers)
if peer_counts:
return round(1.0 * sum(peer_counts) / len(peer_counts), 2) return round(1.0 * sum(peer_counts) / len(peer_counts), 2)
else:
return 0.0
name = p['name'] name = p['name']
d = self._resolve_name(name, force_refresh=True) d = self._resolve_name(name, force_refresh=True)
d.addCallback(get_sd_hash) d.addCallback(get_sd_hash)
d.addCallback(self._download_sd_blob) d.addCallback(self._download_sd_blob)
d.addCallback(lambda descriptor: [blob.get('blob_hash') for blob in descriptor['blobs']]) d.addCallbacks(lambda descriptor: [blob.get('blob_hash') for blob in descriptor['blobs']],
lambda _: [])
d.addCallback(self.session.blob_tracker.get_availability_for_blobs) d.addCallback(self.session.blob_tracker.get_availability_for_blobs)
d.addCallback(_get_mean) d.addCallback(_get_mean)
d.addCallback(lambda result: self._render_response(result, OK_CODE)) d.addCallback(lambda result: self._render_response(result, OK_CODE))