download status: add time spent paused by the client (when we're serving over a slow HTTP link)

This commit is contained in:
Brian Warner 2008-04-21 12:19:17 -07:00
parent c559769e78
commit f16f48a909
3 changed files with 8 additions and 0 deletions

View File

@ -449,6 +449,7 @@ class FileDownloader:
self._results.timings["cumulative_fetch"] = 0.0
self._results.timings["cumulative_decode"] = 0.0
self._results.timings["cumulative_decrypt"] = 0.0
self._results.timings["paused"] = 0.0
if IConsumer.providedBy(downloadable):
downloadable.registerProducer(self, True)
@ -489,6 +490,7 @@ class FileDownloader:
if self._paused:
return
self._paused = defer.Deferred()
self._paused_at = time.time()
if self._status:
self._status.set_paused(True)
@ -503,6 +505,8 @@ class FileDownloader:
def stopProducing(self):
self.log("Download.stopProducing")
self._stopped = True
paused_for = time.time() - self._paused_at
self._results.timings['paused'] += paused_for
if self._status:
self._status.set_stopped(True)
self._status.set_active(False)

View File

@ -45,6 +45,7 @@
<li>Cumulative Decrypting: <span n:render="time" n:data="time_cumulative_decrypt" />
(<span n:render="rate" n:data="rate_decrypt" />)</li>
</ul>
<li>Paused by client: <span n:render="time" n:data="time_paused" /></li>
</ul>
<li n:render="server_timings" />
</ul>

View File

@ -308,6 +308,9 @@ class DownloadResultsRendererMixin(RateAndTimeMixin):
def data_time_cumulative_decrypt(self, ctx, data):
return self._get_time("cumulative_decrypt")
def data_time_paused(self, ctx, data):
return self._get_time("paused")
def _get_rate(self, name):
d = self.download_results()
def _convert(r):