Skip to content

Commit

Permalink
Merge pull request #68 from RyanMarcus/master
Browse files Browse the repository at this point in the history
Close file handles in ffdec.py
  • Loading branch information
sampsyo committed Jun 28, 2018
2 parents ce88b72 + 0ec91ea commit ac7b1e0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion audioread/ffdec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ac7b1e0

Please sign in to comment.