-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Close file handles in ffdec.py #68
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these! This looks good to me. I left some notes here about where comments and formatting might be useful.
audioread/ffdec.py
Outdated
@@ -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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above doesn't apply to these lines, so it would be nice to use a blank line above them—and to write a new comment explaining why these are here. (For posterity, for example, we might want to record why this goes above the if
block that happens next.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done -- left a brief note.
audioread/ffdec.py
Outdated
|
||
# 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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, since this is separate from the above handling of the subprocess, it would be a good idea to put a blank line above this one. I'm not sure if an explanatory comment would be useful to say something about why this is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment anyway -- feel free to remove it if you believe it is too verbose. :)
So we can refer back to it later, what sort of resource leak warnings were you getting? Are they Python messages? Or something from ffmpeg? |
The errors were Python errors, coming from an execution of a unit test with python3 -m unittest. I think it enables these sorts of warning if an FD is left open after a test finishes. I will copy/paste an error later tonight. |
Close file handles in ffdec.py
Awesome; thanks for clarifying! I merged the changes. ✨ |
This change is triggering a segfault in Beets, see #62 |
Hello!
Thanks for all the hard work putting this library together! It made quickly combining two audio files I had super easy.
This PR just closes the /dev/null, stdout, and stderr FDs when in FFmpeg mode to avoid resource leak warnings.
Let me know if there are any issues,
Ryan