feat: テレメトリ機能を追加し、アプリの起動・終了時にイベントを送信するように変更
This commit is contained in:
@@ -460,14 +460,20 @@ class Main:
|
||||
"""Read lines from stdin, parse JSON and enqueue requests.
|
||||
|
||||
Uses blocking readline but honors stop via _stop_event checked between reads.
|
||||
EOF on stdin indicates the frontend has closed; trigger app_closed event.
|
||||
"""
|
||||
while not self._stop_event.is_set():
|
||||
try:
|
||||
line = sys.stdin.readline()
|
||||
if not line:
|
||||
# EOF reached; sleep briefly and re-check stop event
|
||||
time.sleep(0.1)
|
||||
continue
|
||||
# EOF reached - frontend has closed connection
|
||||
# Trigger telemetry shutdown to send app_closed event
|
||||
printLog("Frontend disconnected (stdin EOF)", {"event": "frontend_closed"})
|
||||
try:
|
||||
self.controller.shutdown()
|
||||
except Exception:
|
||||
errorLogging()
|
||||
break
|
||||
received_data = json.loads(line.strip())
|
||||
|
||||
if received_data:
|
||||
@@ -584,6 +590,12 @@ class Main:
|
||||
Args:
|
||||
wait: maximum seconds to wait for threads to join.
|
||||
"""
|
||||
# Controller 経由でシャットダウン(model.shutdown() → telemetry.shutdown() が呼ばれる)
|
||||
try:
|
||||
self.controller.shutdown()
|
||||
except Exception:
|
||||
errorLogging()
|
||||
|
||||
self._stop_event.set()
|
||||
# give threads a chance to exit
|
||||
start = time.time()
|
||||
|
||||
Reference in New Issue
Block a user