ajayyy / DeArrowThumbnailCache

GNU Affero General Public License v3.0
22 stars 5 forks source link

Replace python-ffmpeg with own implementation #8

Closed mini-bomba closed 1 year ago

mini-bomba commented 1 year ago

python-ffmpeg didn't play well with rq's timeout exceptions, causing deadlocks.

This PR replaces python-ffmpeg with a much simpler function that doesn't cause deadlocks on interruption, at a cost of having to think more about ffmpeg's input arguments. It raises FFmpegError if ffmpeg exits with a non-zero exit code. It also passes on the TimeoutExpired error that it may get from subprocess if ffmpeg times out. This causes rq's logging to throw a weird error if uncaught, but doesn't cause the worker to die or become unusable.

I've tested this PR by running about 200 videos through it - I encountered no deadlocks or dead workers.

mini-bomba commented 1 year ago

Simplified the implementation even more by just using the built-in subprocess.run and letting it handle the timeout properly.