Skip to content

fix(separator): pass timeout to AsyncResult.get in Separator.join - #961

Open
AyhamJo7 wants to merge 2 commits into
deezer:masterfrom
AyhamJo7:fix/956-separator-join-timeout
Open

AyhamJo7 wants to merge 2 commits into
deezer:masterfrom
AyhamJo7:fix/956-separator-join-timeout

Conversation

@AyhamJo7

Copy link
Copy Markdown

Description

Fixes #956.

Separator.join(self, timeout: int = 200) previously called task.get() without a timeout argument before calling task.wait(timeout=timeout). Because AsyncResult.get() blocks indefinitely when timeout is omitted, the timeout parameter was silently ignored and task.wait(timeout=timeout) was unreachable until the task had already finished.

Changes

  • Replaced task.get() + task.wait(timeout=timeout) in spleeter/separator.py with task.get(timeout=timeout), which bounds the wait per task (multiprocessing.TimeoutError on timeout) while continuing to propagate worker exceptions.
  • Added regression tests in tests/test_separator.py (test_join_respects_timeout, test_join_drains_tasks_and_propagates_errors).

How this patch was tested

  • Reproduced the unbounded wait before the fix using multiprocessing.pool.ThreadPool (Separator.join(timeout=0.05) blocked until task completion instead of raising multiprocessing.TimeoutError).
  • Ran pytest -v tests/test_separator.py -k test_join -> 2 passed.
  • Ran black spleeter/separator.py --check and isort spleeter/separator.py --check -> clean.

Now that the timeout is honoured, the old 200-second default would make the CLI raise on batches: join pops tasks last-first, so the wait for the last task includes the time the pool spends on all earlier files. Defaulting to None keeps the CLI and existing callers unbounded as before, while an explicit timeout bounds each task.
@AyhamJo7

Copy link
Copy Markdown
Author

Follow-up in c788efb: with the timeout now enforced, the old 200-second default would make spleeter separate raise TimeoutError on longer batches, because the CLI calls separator.join() without arguments and the wait for the last task includes the time spent on earlier files. The default is now None (unbounded, same as the released behaviour), and an explicit join(timeout=...) bounds each task as #956 asks. Added a test for the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Separator.join(timeout=...) parameter is silently ignored

1 participant