fix exit hanging

This commit is contained in:
Tim Bendt
2025-12-16 21:17:35 -05:00
parent d7c82a0da0
commit d33d6a4dc4
2 changed files with 28 additions and 2 deletions

BIN
.coverage

Binary file not shown.

View File

@@ -26,7 +26,17 @@ DEFAULT_SYNC_INTERVAL = 300
# SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
# Alternative spinners you could use:
# SPINNER_FRAMES = ["◢", "◣", "◤", "◥"] # Rotating triangle
SPINNER_FRAMES = ["▰▱▱▱▱", "▰▰▱▱▱", "▰▰▰▱▱", "▰▰▰▰▱", "▰▰▰▰▰", "▱▰▰▰▰", "▱▱▰▰▰", "▱▱▱▰▰", "▱▱▱▱▰"] # Loading bar
SPINNER_FRAMES = [
"▰▱▱▱▱",
"▰▰▱▱▱",
"▰▰▰▱▱",
"▰▰▰▰▱",
"▰▰▰▰▰",
"▱▰▰▰▰",
"▱▱▰▰▰",
"▱▱▱▰▰",
"▱▱▱▱▰",
] # Loading bar
# SPINNER_FRAMES = ["⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"] # Braille dots
# SPINNER_FRAMES = ["◐", "◓", "◑", "◒"] # Circle quarters
# SPINNER_FRAMES = ["⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"] # Braille orbit
@@ -296,6 +306,13 @@ class SyncDashboard(App):
self._log_to_task("archive", "Dashboard initialized. Waiting to start sync...")
self._mounted.set()
def on_unmount(self) -> None:
"""Clean up when the dashboard is unmounted."""
if self._countdown_task:
self._countdown_task.cancel()
if self._spinner_task:
self._spinner_task.cancel()
def on_list_view_selected(self, event: ListView.Selected) -> None:
"""Handle task selection from the list."""
if isinstance(event.item, TaskListItem):
@@ -677,4 +694,13 @@ async def run_dashboard_sync():
await asyncio.sleep(1)
# Run dashboard and sync loop concurrently
await asyncio.gather(dashboard.run_async(), sync_loop())
# When dashboard exits, cancel the sync loop
sync_task = asyncio.create_task(sync_loop())
try:
await dashboard.run_async()
finally:
sync_task.cancel()
try:
await sync_task
except asyncio.CancelledError:
pass