Skip to content

Commit

Permalink
Merge pull request #1926 from ptmcg/ptmcg_task_progress_use_deque_wit…
Browse files Browse the repository at this point in the history
…h_maxlen

task._progress change default_factory to create deque(maxlen=1000), t…
  • Loading branch information
willmcgugan committed Feb 7, 2022
2 parents 0ffbf93 + e1c595c commit 9dd56e0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions rich/progress.py
Expand Up @@ -475,7 +475,7 @@ class Task:
"""Optional[float]: The last speed for a finished task."""

_progress: Deque[ProgressSample] = field(
default_factory=deque, init=False, repr=False
default_factory=lambda: deque(maxlen=1000), init=False, repr=False
)

_lock: RLock = field(repr=False, default_factory=RLock)
Expand Down Expand Up @@ -813,8 +813,6 @@ def update(
popleft = _progress.popleft
while _progress and _progress[0].timestamp < old_sample_time:
popleft()
while len(_progress) > 1000:
popleft()
if update_completed > 0:
_progress.append(ProgressSample(current_time, update_completed))
if task.completed >= task.total and task.finished_time is None:
Expand Down

0 comments on commit 9dd56e0

Please sign in to comment.