Skip to content

Commit

Permalink
Kill the ffmpeg process in LoadFFmpeg's destructor.
Browse files Browse the repository at this point in the history
This avoids a broken-pipe warning from ffmpeg when using -l.

(Strictly this will only work properly in CPython, since other
implementations like PyPy don't guarantee the destructor will actually
be run. Fixing this properly would mean changing the loader interface to
have an explicit close() operation.)
  • Loading branch information
atsampson committed Aug 4, 2019
1 parent d8142c3 commit 52d0710
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lddutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ def __init__(self, input_args=[], output_args=[]):
self.rewind_size = 2 * 1024 * 1024
self.rewind_buf = b''

def __del__(self):
if self.ffmpeg is not None:
self.ffmpeg.kill()
self.ffmpeg.wait()

def _read_data(self, count):
"""Read data as bytes from ffmpeg, append it to the rewind buffer, and
return it. May return less than count bytes if EOF is reached."""
Expand Down

0 comments on commit 52d0710

Please sign in to comment.