Skip to content

Commit

Permalink
Merge pull request #930 from willmcgugan/live-deadlock
Browse files Browse the repository at this point in the history
fix deadlock
  • Loading branch information
willmcgugan committed Jan 15, 2021
2 parents aca0b60 + 95618a0 commit 88b07b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [9.8.2] - 2021-01-15

### Fixed

- Fixed deadlock in live https://github.com/willmcgugan/rich/issues/927

## [9.8.1] - 2021-01-13

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Expand Up @@ -2,7 +2,7 @@
name = "rich"
homepage = "https://github.com/willmcgugan/rich"
documentation = "https://rich.readthedocs.io/en/latest/"
version = "9.8.1"
version = "9.8.2"
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
authors = ["Will McGugan <willmcgugan@gmail.com>"]
license = "MIT"
Expand All @@ -18,6 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Typing :: Typed"
]
include = ["rich/py.typed"]

Expand Down
8 changes: 5 additions & 3 deletions rich/live.py
Expand Up @@ -40,7 +40,8 @@ def stop(self) -> None:
def run(self) -> None:
while not self.done.wait(1 / self.refresh_per_second):
with self.live._lock:
self.live.refresh()
if not self.done.is_set():
self.live.refresh()


class _LiveRender(LiveRender):
Expand Down Expand Up @@ -157,8 +158,6 @@ def stop(self) -> None:
try:
if self.auto_refresh and self._refresh_thread is not None:
self._refresh_thread.stop()
self._refresh_thread.join()
self._refresh_thread = None
# allow it to fully render on the last even if overflow
self.vertical_overflow = "visible"
if not self.console.is_jupyter:
Expand All @@ -179,6 +178,9 @@ def stop(self) -> None:
# jupyter last refresh must occur after console pop render hook
# i am not sure why this is needed
self.refresh()
if self.auto_refresh and self._refresh_thread is not None:
self._refresh_thread.join()
self._refresh_thread = None

def __enter__(self) -> "Live":
self.start()
Expand Down

0 comments on commit 88b07b3

Please sign in to comment.