beetbox / audioread

cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python
MIT License
481 stars 108 forks source link

Opening mp3 fails silently when called from a child process on macOS #90

Closed dannyshisler closed 5 years ago

dannyshisler commented 5 years ago

I'm using stefuna to orchestrate some audio/video processing. The library creates workers initialised through a thread pool. My processing pipeline uses librosa which depends on audioread.

On my Mac (10.14.3) when librosa tries to use _coreaudio.ExtAudioFileOpenURL to open the audio mp3 file (at https://github.com/beetbox/audioread/blob/master/audioread/macca.py#L219) the process exits silently and the pool reinitialises.

It works fine when called from the main thread.

I don't understand why it fails, why it fails silently and what (if anything) I can do about it? Any help would be much appreciated!

dannyshisler commented 5 years ago

The author of stefuna has very kindly helped to resolve this issue. It's related to the way that threads are initialised, if they are forked rather than spawned then there is a known issue on macOS that can cause forked processes to fail when they call Objective-C code.

Spawning the thread(s) rather than forking them has resolved the problem.

More info in the issue here https://github.com/irothschild/stefuna/issues/13