diff --git a/audioread/ffdec.py b/audioread/ffdec.py index 77fa7e4..e742271 100644 --- a/audioread/ffdec.py +++ b/audioread/ffdec.py @@ -265,11 +265,20 @@ def close(self): # `returncode`. self.proc.poll() + # 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() + # Kill the process if it is still running. if self.proc.returncode is None: self.proc.kill() self.proc.wait() - self.devnull.close() + + # Close the handle to os.devnull, which is opened regardless of if + # a subprocess is successfully created + self.devnull.close() def __del__(self): self.close()