Add an option allowing use without a multiprocessing pool... #251
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[Spleeter] - Add an option allowing use without a multiprocessing pool
Recreating this PR from #231 by request from reviewers to trigger CI.
This PR adds a keyword argument allowing a
Separator
to be used asynchronously within amultiprocessing
-created subprocess (by bypassing itsmultiprocessing.Pool
and doing its work in the main process). Without this option enabled, attempting to do so will fail with an error "AssertionError: daemonic processes are not allowed to have children."How this patch was tested
I'm working on a tool that calls
separate_to_file
usingPool.apply_async
. Prior to this patch it failed with the AssertionError above. After applying the patch and passingmultiprocess=False
to theSeparator
constructor the separation works as expected.Documentation link and external references
Info about the exception in the Python docs: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Process.daemon
Here's a SO example of someone encountering the same exception in a similar scenario: https://stackoverflow.com/questions/51485212/multiprocessing-gives-assertionerror-daemonic-processes-are-not-allowed-to-have
It seems that this problem could also be avoided by using a
ThreadPool
but I understand spleeter to be fairly CPU-bound so threads aren't a great solution. However if spleeter does most of its heavy lifting in its own subprocesses, it might work to use aThreadPool
instead. I'm willing to try it if you'd prefer.