Merge pull request #5124 from gaul/ui/limit-progress

Limit progress updates to avoid swamping the TTY
This commit is contained in:
Pradyun Gedam 2018-08-13 23:32:10 +05:30 committed by GitHub
commit 62b03f2a3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

1
news/5124.trivial Normal file
View File

@ -0,0 +1 @@
Limit progress bar update interval to 200 ms.

View File

@ -137,6 +137,7 @@ class DownloadProgressMixin(object):
def __init__(self, *args, **kwargs):
super(DownloadProgressMixin, self).__init__(*args, **kwargs)
self.message = (" " * (get_indentation() + 2)) + self.message
self.last_update = 0.0
@property
def downloaded(self):
@ -161,6 +162,15 @@ class DownloadProgressMixin(object):
self.next(n)
self.finish()
def update(self):
# limit updates to avoid swamping the TTY
now = time.time()
if now < self.last_update + 0.2:
return
self.last_update = now
super(DownloadProgressMixin, self).update()
class WindowsMixin(object):