mirror of
https://github.com/HiMeditator/auto-caption.git
synced 2026-02-04 04:14:42 +08:00
feat(engine): 优化字幕引擎通信和控制逻辑,优化窗口信息展示
- 优化错误处理和引擎重启逻辑 - 添加字幕引擎强制终止功能 - 调整通知和错误提示的显示位置 - 优化日志记录精度到毫秒级
This commit is contained in:
@@ -6,7 +6,7 @@ from utils import thread_data, stdout_cmd, stderr
|
||||
|
||||
def handle_client(client_socket):
|
||||
global thread_data
|
||||
while True:
|
||||
while thread_data.status == 'running':
|
||||
try:
|
||||
data = client_socket.recv(4096).decode('utf-8')
|
||||
if not data:
|
||||
@@ -14,9 +14,8 @@ def handle_client(client_socket):
|
||||
data = json.loads(data)
|
||||
|
||||
if data['command'] == 'stop':
|
||||
if thread_data.status == 'running':
|
||||
thread_data.status = 'stop'
|
||||
break
|
||||
thread_data.status = 'stop'
|
||||
break
|
||||
except Exception as e:
|
||||
stderr(f'Communication error: {e}')
|
||||
break
|
||||
@@ -29,7 +28,7 @@ def start_server(port: int):
|
||||
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
server.bind(('localhost', port))
|
||||
server.listen(1)
|
||||
stdout_cmd('ready')
|
||||
stdout_cmd('connect')
|
||||
|
||||
client, addr = server.accept()
|
||||
client_handler = threading.Thread(target=handle_client, args=(client,))
|
||||
|
||||
Reference in New Issue
Block a user