Commit 07cae1b7 by 程裕兵

fix(luna-tts): protect send_message from BrokenPipeError

parent 72982948
...@@ -56,10 +56,13 @@ def read_message(): ...@@ -56,10 +56,13 @@ def read_message():
def send_message(msg): def send_message(msg):
"""Send a native messaging message to stdout.""" """Send a native messaging message to stdout."""
try:
encoded = json.dumps(msg, ensure_ascii=False).encode('utf-8') encoded = json.dumps(msg, ensure_ascii=False).encode('utf-8')
sys.stdout.buffer.write(struct.pack('=I', len(encoded))) sys.stdout.buffer.write(struct.pack('=I', len(encoded)))
sys.stdout.buffer.write(encoded) sys.stdout.buffer.write(encoded)
sys.stdout.buffer.flush() sys.stdout.buffer.flush()
except (BrokenPipeError, OSError):
pass
def download_audio(url: str, dest: Path) -> bool: def download_audio(url: str, dest: Path) -> bool:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment