mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Merge pull request #5124 from gaul/ui/limit-progress
Limit progress updates to avoid swamping the TTY
This commit is contained in:
commit
62b03f2a3a
2 changed files with 11 additions and 0 deletions
1
news/5124.trivial
Normal file
1
news/5124.trivial
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Limit progress bar update interval to 200 ms.
|
|
@ -137,6 +137,7 @@ class DownloadProgressMixin(object):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(DownloadProgressMixin, self).__init__(*args, **kwargs)
|
super(DownloadProgressMixin, self).__init__(*args, **kwargs)
|
||||||
self.message = (" " * (get_indentation() + 2)) + self.message
|
self.message = (" " * (get_indentation() + 2)) + self.message
|
||||||
|
self.last_update = 0.0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def downloaded(self):
|
def downloaded(self):
|
||||||
|
@ -161,6 +162,15 @@ class DownloadProgressMixin(object):
|
||||||
self.next(n)
|
self.next(n)
|
||||||
self.finish()
|
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):
|
class WindowsMixin(object):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue