restore refresh thread check for None

This commit is contained in:
Will McGugan 2020-05-24 15:13:22 +01:00
parent f3a078cc2f
commit 5a3bd44938
1 changed files with 4 additions and 3 deletions

View File

@ -431,20 +431,21 @@ class Progress:
def stop(self) -> None: def stop(self) -> None:
"""Stop the progress display.""" """Stop the progress display."""
assert self._refresh_thread is not None
with self._lock: with self._lock:
if not self._started: if not self._started:
return return
self._started = False self._started = False
try: try:
if self.auto_refresh: if self.auto_refresh and self._refresh_thread is not None:
self._refresh_thread.stop() self._refresh_thread.stop()
self.refresh() self.refresh()
if self.console.is_terminal: if self.console.is_terminal:
self.console.line() self.console.line()
finally: finally:
self.console.show_cursor(True) self.console.show_cursor(True)
self._refresh_thread.join() if self._refresh_thread is not None:
self._refresh_thread.join()
self._refresh_thread = None
def __enter__(self) -> "Progress": def __enter__(self) -> "Progress":
self.start() self.start()