Skip to content

Commit 610fd75

Browse files
authored
Merge pull request #3402 from Textualize/progress-exit
exit track thread
2 parents 01f708e + 06c1228 commit 610fd75

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Fixed `Table` rendering of box elements so "footer" elements truly appear at bottom of table, "mid" elements in main table body.
1414
- Fixed styles in Panel when Text objects are used for title https://github.com/Textualize/rich/pull/3401
1515
- Fix pretty repr for `collections.deque` https://github.com/Textualize/rich/pull/2864
16+
- Thread used in progress.track will exit if an exception occurs in a generator https://github.com/Textualize/rich/pull/3402
17+
- Progress track thread is now a daemon thread https://github.com/Textualize/rich/pull/3402
1618

1719
### Changed
1820

rich/progress.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ def __init__(self, progress: "Progress", task_id: "TaskID", update_period: float
7070
self.done = Event()
7171

7272
self.completed = 0
73-
super().__init__()
73+
super().__init__(daemon=True)
7474

7575
def run(self) -> None:
7676
task_id = self.task_id
7777
advance = self.progress.advance
7878
update_period = self.update_period
7979
last_completed = 0
8080
wait = self.done.wait
81-
while not wait(update_period):
81+
while not wait(update_period) and self.progress.live.is_started:
8282
completed = self.completed
8383
if last_completed != completed:
8484
advance(task_id, completed - last_completed)

tests/test_progress.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def test_wrap_file_task_total() -> None:
646646
os.remove(filename)
647647

648648

649-
def test_task_progress_column_speed():
649+
def test_task_progress_column_speed() -> None:
650650
speed_text = TaskProgressColumn.render_speed(None)
651651
assert speed_text.plain == ""
652652

0 commit comments

Comments
 (0)