diff --git a/CHANGELOG.md b/CHANGELOG.md index b80f65c38..e47aa39a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/rich/progress.py b/rich/progress.py index 8c3563bf5..aa9664958 100644 --- a/rich/progress.py +++ b/rich/progress.py @@ -70,7 +70,7 @@ 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 @@ -78,7 +78,7 @@ def run(self) -> None: 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) diff --git a/tests/test_progress.py b/tests/test_progress.py index 72497a0ca..0be683c3e 100644 --- a/tests/test_progress.py +++ b/tests/test_progress.py @@ -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 == ""