Merge pull request #1364 from evandroforks/fix_unclosed_python_file

Fix ResourceWarning: unclosed file <_io.BufferedWriter name=5>
This commit is contained in:
Damien Elmes 2021-09-13 12:01:34 +10:00 committed by GitHub
commit 59c604e774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
@ -321,6 +323,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: