Fail better when timings data isn't available

This commit is contained in:
Sajith Sasidharan 2020-07-08 13:08:19 -04:00
parent 112cfc1da5
commit 51d6307b45

View File

@ -707,7 +707,9 @@ class DownloadStatusElement(Element):
return tag(str(self.download_results().file_size)) return tag(str(self.download_results().file_size))
def _get_time(self, name): def _get_time(self, name):
if self.download_results().timings:
return self.download_results().timings.get(name) return self.download_results().timings.get(name)
return None
@renderer @renderer
def time_total(self, req, tag): def time_total(self, req, tag):
@ -748,6 +750,8 @@ class DownloadStatusElement(Element):
def _get_rate(self, name): def _get_rate(self, name):
r = self.download_results() r = self.download_results()
file_size = r.file_size file_size = r.file_size
duration = None
if r.timings:
duration = r.timings.get(name) duration = r.timings.get(name)
return compute_rate(file_size, duration) return compute_rate(file_size, duration)