From 14e2d0d1027414d7cb7b96e5b9ba1ca7313121ab Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Wed, 8 Sep 2021 21:00:21 -0300 Subject: [PATCH 1/2] Fix ResourceWarning: unclosed file <_io.BufferedWriter name=5> https://forums.ankiweb.net/t/aqt-sound-py-resourcewarning-unclosed-file-io-bufferedwriter-name-5/13070 --- qt/aqt/sound.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index 590776226..dd8e49c55 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -321,6 +321,8 @@ 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}") + if self._process.stdin: + self._process.stdin.close() self._process = None return except subprocess.TimeoutExpired: From c1b861a7b05052b26f4f213be25e7eaf996683eb Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Thu, 9 Sep 2021 18:33:23 -0300 Subject: [PATCH 2/2] Add clone stdin to another _process deletion --- qt/aqt/sound.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index dd8e49c55..3001d2c68 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -313,6 +313,8 @@ class SimpleProcessPlayer(Player): # pylint: disable=abstract-method if self._terminate_flag: self._process.terminate() self._process.wait(1) + if self._process.stdin: + self._process.stdin.close() self._process = None return