fix: App beendet sich nicht mehr nach Hotkey-Änderung in Einstellungen

run() wartete auf den Hotkey-Task direkt; beim Neustart des Listeners
wurde dieser Task beendet und run() kehrte zurück. Jetzt wartet run()
auf ein asyncio.Event (_quit_event), das nur durch _quit() gesetzt wird.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-11 11:15:55 +02:00
parent 71806cd0b8
commit 7319ff6299
+5 -3
View File
@@ -22,6 +22,7 @@ class App:
self._config = config
self._loop: asyncio.AbstractEventLoop | None = None
self._hotkey_task: asyncio.Task | None = None
self._quit_event: asyncio.Event | None = None
self.recorder = Recorder(
sample_rate=config.sample_rate,
@@ -63,8 +64,8 @@ class App:
def _quit(self) -> None:
"""Beendet die Anwendung sauber."""
if self._loop is not None:
self._loop.call_soon_threadsafe(self._loop.stop)
if self._loop is not None and self._quit_event is not None:
self._loop.call_soon_threadsafe(self._quit_event.set)
def _open_settings(self) -> None:
"""Öffnet den Einstellungs-Dialog."""
@@ -97,10 +98,11 @@ class App:
async def run(self) -> None:
"""Startet den Hauptloop."""
self._loop = asyncio.get_running_loop()
self._quit_event = asyncio.Event()
logger.info("whisper-local gestartet, warte auf Hotkey...")
self.tray.start()
self._hotkey_task = asyncio.create_task(self.hotkey.listen())
await self._hotkey_task
await self._quit_event.wait()
def main():