From 2a2469e7a2287582f0299be538ec8a4a6f623558 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 27 Sep 2021 18:43:16 +1000 Subject: [PATCH] Revert "Revert "Merge pull request #1364 from evandroforks/fix_unclosed_python_file"" This reverts commit a2ac197fd786b31880c8334735b4a2d6bd76b0bd. Looks like it wasn't the cause of the previously reported problem: https://forums.ankiweb.net/t/2-1-48-tts-problem/13587/2 --- qt/aqt/sound.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index 590776226..9b287b667 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -313,6 +313,11 @@ class SimpleProcessPlayer(Player): # pylint: disable=abstract-method if self._terminate_flag: self._process.terminate() self._process.wait(1) + try: + if self._process.stdin: + self._process.stdin.close() + except Exception as e: + print("unable to close stdin:", e) self._process = None return @@ -321,6 +326,11 @@ class SimpleProcessPlayer(Player): # pylint: disable=abstract-method self._process.wait(0.1) if self._process.returncode != 0: print(f"player got return code: {self._process.returncode}") + try: + if self._process.stdin: + self._process.stdin.close() + except Exception as e: + print("unable to close stdin:", e) self._process = None return except subprocess.TimeoutExpired: