|
|
@@ -172,14 +172,26 @@ class TrainerApplication(IApplication):
|
|
|
except Exception as e:
|
|
|
perror(f"Intent-Training Fehler: {e}")
|
|
|
|
|
|
- # Training starten und Fortschritt loggen
|
|
|
- import threading
|
|
|
- train_thread = threading.Thread(target=run_training, daemon=True)
|
|
|
+ # Training synchron in Thread ausfuehren
|
|
|
+ # (nicht daemon, damit der Prozess wartet bis fertig)
|
|
|
+ pinfo(" Starte Training (kann einige Minuten dauern)...")
|
|
|
+
|
|
|
+ result_holder: list[Exception | None] = [None]
|
|
|
+
|
|
|
+ def run_training_sync():
|
|
|
+ try:
|
|
|
+ trainer.train(progress_queue, pause_flag, stop_flag)
|
|
|
+ except Exception as e:
|
|
|
+ result_holder[0] = e
|
|
|
+
|
|
|
+ train_thread = __import__("threading").Thread(
|
|
|
+ target=run_training_sync, daemon=False,
|
|
|
+ )
|
|
|
train_thread.start()
|
|
|
|
|
|
# Fortschritt abfragen bis Training fertig
|
|
|
while train_thread.is_alive():
|
|
|
- await asyncio.sleep(0.5)
|
|
|
+ await asyncio.sleep(1.0)
|
|
|
while not progress_queue.empty():
|
|
|
try:
|
|
|
progress = progress_queue.get_nowait()
|
|
|
@@ -188,6 +200,8 @@ class TrainerApplication(IApplication):
|
|
|
except Exception:
|
|
|
break
|
|
|
|
|
|
+ train_thread.join()
|
|
|
+
|
|
|
# Restliche Nachrichten lesen
|
|
|
while not progress_queue.empty():
|
|
|
try:
|
|
|
@@ -197,8 +211,10 @@ class TrainerApplication(IApplication):
|
|
|
except Exception:
|
|
|
break
|
|
|
|
|
|
- train_thread.join(timeout=5)
|
|
|
- pinfo("Intent-Training abgeschlossen")
|
|
|
+ if result_holder[0]:
|
|
|
+ perror(f"Intent-Training Fehler: {result_holder[0]}")
|
|
|
+ else:
|
|
|
+ pinfo("Intent-Training abgeschlossen")
|
|
|
|
|
|
except ImportError as e:
|
|
|
perror(f"Intent-Trainer nicht verfuegbar: {e}")
|