Skip to content

Commit

Permalink
refactor: Improve non-QUIET startup time
Browse files Browse the repository at this point in the history
- Change: Wake up LoadingIndicator thread when done processing sources.
  - Waiting for the thread to wake up added to the startup time.
  • Loading branch information
AnonymouX47 committed May 8, 2023
1 parent f7b2c56 commit aa05a76
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/termvisage/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ def main() -> None:
raise interrupt from None

notify.stop_loading()
notify.cli_loading_interrupt.set()
while notify.is_loading():
pass

Expand Down
3 changes: 2 additions & 1 deletion src/termvisage/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def load() -> None:
stream.flush()
if _n_loading <= 0:
break
sleep(0.25)
cli_loading_interrupt.wait(0.25) # Doubles as a delay
stream.write(" " * 3 + "\b" * 3)
stream.flush()
if _n_loading > -1:
Expand Down Expand Up @@ -180,6 +180,7 @@ def stop_loading() -> None:

_loading = Event()
_n_loading = 0
cli_loading_interrupt = Event()

# Set from `.logging.init_log()`.
loading_indicator: Optional[Thread] = None

0 comments on commit aa05a76

Please sign in to comment.