slhck / ffmpeg-normalize

Audio Normalization for Python/ffmpeg
MIT License
1.25k stars 117 forks source link

Set tqdm lock for logging only when multiprocessing is available #157

Closed Geekfish closed 3 years ago

Geekfish commented 3 years ago

Multiprocessing is not available in all environments, for example on AWS lambda python run time lacks /dev/shm, so trying to acquire a multiprocessing Lock throws an OSError.

The module could also be entirely missing in some cases (ex. Jython, although this library doesn't support Jython anyway because Jython only supports up to python 2.7).

The solution to this is to only try to set the lock when multiprocessing is available. The tqdm library solves this in the same manner.

For more details, see: #156

Geekfish commented 3 years ago

Hey @slhck !

Tests seem to pass on python 3.9 (CPython). I have run a couple of manual tests to check that the progress bar + logging still work the same as in master. I have also installed ffmpeg-normalize from my branch on an AWS lambda, to check that no exceptions occur.

Let me know if you think of something else I might have missed, or if there's a way we could further test this for regression!

slhck commented 3 years ago

Looks good to me. Thanks for your quick and very comprehensive PR! Will release this in a minute.

Geekfish commented 3 years ago

That's great @slhck, thanks again for being so responsive with this and for your all work on this library!