I’d like to use an external audio i/o library that requires call-once initialization before usage (e.g. torchaudio uses sox that requires https://pytorch.org/audio/#torchaudio.initialize_sox ) and call-once resource cleaning after usage is finished.
What is the correct way to use multi-threaded DataLoader wrt shared library initialization and cleanup? Does worker thread creation reload the shared library many times in separate processes? Does start_method affect any of these?
Usecase: I designed my own ffmpeg-based C extension for reading audio: https://github.com/vadimkantorov/readaudio/blob/master/decode_audio.c#L48. In most ffmpeg versions (up until 4.0 which is not shipped in stable Ubuntu yet) the user must call onc av_register_all() once before initialization.