From 72ed349c12a16ab741cb02abc4de8f2e8e7fe4ee Mon Sep 17 00:00:00 2001 From: Ryan Marcus Date: Wed, 27 Jun 2018 13:36:56 -0700 Subject: [PATCH 1/3] Close file handles --- audioread/ffdec.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/audioread/ffdec.py b/audioread/ffdec.py index 77fa7e4..2d3e30c 100644 --- a/audioread/ffdec.py +++ b/audioread/ffdec.py @@ -264,12 +264,14 @@ def close(self): # ffmpeg closes normally on its own, but never updates # `returncode`. self.proc.poll() + self.proc.stdout.close() + self.proc.stderr.close() # Kill the process if it is still running. if self.proc.returncode is None: self.proc.kill() self.proc.wait() - self.devnull.close() + self.devnull.close() def __del__(self): self.close() From feb02c12b2bfbf62e5d33fd0940348390dd0164b Mon Sep 17 00:00:00 2001 From: Ryan Marcus Date: Wed, 27 Jun 2018 14:55:10 -0700 Subject: [PATCH 2/3] added comments and fixed paragraphing --- audioread/ffdec.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/audioread/ffdec.py b/audioread/ffdec.py index 2d3e30c..de0adac 100644 --- a/audioread/ffdec.py +++ b/audioread/ffdec.py @@ -264,6 +264,8 @@ def close(self): # ffmpeg closes normally on its own, but never updates # `returncode`. self.proc.poll() + + # Close the stdout and stderr streams that were opened by Popen. self.proc.stdout.close() self.proc.stderr.close() @@ -271,6 +273,9 @@ def close(self): if self.proc.returncode is None: self.proc.kill() self.proc.wait() + + # Close the handle to os.devnull, which is opened regardless of if + # a subprocess is successfully created self.devnull.close() def __del__(self): From 0ec91ea5e34f692e2ee3992cdac17796a07c66d5 Mon Sep 17 00:00:00 2001 From: Ryan Marcus Date: Wed, 27 Jun 2018 14:56:32 -0700 Subject: [PATCH 3/3] added comments and fixed paragraphing --- audioread/ffdec.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/audioread/ffdec.py b/audioread/ffdec.py index de0adac..e742271 100644 --- a/audioread/ffdec.py +++ b/audioread/ffdec.py @@ -265,7 +265,9 @@ def close(self): # `returncode`. self.proc.poll() - # Close the stdout and stderr streams that were opened by Popen. + # Close the stdout and stderr streams that were opened by Popen, + # which should occur regardless of if the process terminated + # cleanly. self.proc.stdout.close() self.proc.stderr.close()