Skip to content

Commit

Permalink
Merge pull request #3402 from Textualize/progress-exit
Browse files Browse the repository at this point in the history
exit track thread
  • Loading branch information
willmcgugan authored Jul 1, 2024
2 parents 01f708e + 06c1228 commit 610fd75
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed `Table` rendering of box elements so "footer" elements truly appear at bottom of table, "mid" elements in main table body.
- Fixed styles in Panel when Text objects are used for title https://github.com/Textualize/rich/pull/3401
- Fix pretty repr for `collections.deque` https://github.com/Textualize/rich/pull/2864
- Thread used in progress.track will exit if an exception occurs in a generator https://github.com/Textualize/rich/pull/3402
- Progress track thread is now a daemon thread https://github.com/Textualize/rich/pull/3402

### Changed

Expand Down
4 changes: 2 additions & 2 deletions rich/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ def __init__(self, progress: "Progress", task_id: "TaskID", update_period: float
self.done = Event()

self.completed = 0
super().__init__()
super().__init__(daemon=True)

def run(self) -> None:
task_id = self.task_id
advance = self.progress.advance
update_period = self.update_period
last_completed = 0
wait = self.done.wait
while not wait(update_period):
while not wait(update_period) and self.progress.live.is_started:
completed = self.completed
if last_completed != completed:
advance(task_id, completed - last_completed)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def test_wrap_file_task_total() -> None:
os.remove(filename)


def test_task_progress_column_speed():
def test_task_progress_column_speed() -> None:
speed_text = TaskProgressColumn.render_speed(None)
assert speed_text.plain == ""

Expand Down

0 comments on commit 610fd75

Please sign in to comment.