Skip to content

replaygain: threads: 0 in config crashes beet replaygain with ValueError (only --threads 0 works) #7113

Open
uoguelph-engg4450/F26-Group11-beets
#1

Description

@Evreu1pro

Problem

threads: 0 in the replaygain config crashes beet replaygain instead of disabling the pool. Only --threads 0 on the command line works. This came up in passing in #7112 ("that is a separate issue"), so filing it so it doesn't get lost.

Minimal config (empty library is enough):

plugins: replaygain
replaygain:
  backend: ffmpeg
  threads: 0
$ beet replaygain
...
  File "/usr/lib/python3.13/multiprocessing/pool.py", line 205, in __init__
    raise ValueError("Number of processes must be at least 1")
ValueError: Number of processes must be at least 1

beet replaygain --threads 0 with the same config runs fine ("Analyzing 0 tracks ~ ffmpeg backend...").

If I'm reading command_func right (master, b8711d8), the reason is that opts.threads is None when the flag isn't passed, so opts.threads != 0 is true and None or self.config["threads"].get(int) gives 0 → ThreadPool(0). The import path already guards this (and threads before open_pool), only the CLI command doesn't.

Something like this fixes it for me:

-            # Bypass self.open_pool() if called with  `--threads 0`
-            if opts.threads != 0:
-                threads: int = opts.threads or self.config["threads"].get(int)
+            # Bypass self.open_pool() if called with `--threads 0` or if
+            # `threads: 0` is set in the config
+            threads: int = (
+                opts.threads
+                if opts.threads is not None
+                else self.config["threads"].get(int)
+            )
+            if threads:
                 self.open_pool(threads)

With it, threads: 0 runs without the pool, threads: 2 still opens it, --threads 0 still overrides, and test/plugins/test_replaygain.py gives 25 passed, 22 skipped locally (the skips are the missing gstreamer/audiotools backends). Happy to open a PR with a test if that's welcome. The docs only mention --threads 0 for disabling parallelism, so it might be worth one line there too.

Setup

  • OS: Debian 13 (trixie)
  • Python version: 3.13.5
  • beets version: 2.14.1 (master, b8711d8)
  • Turning off plugins made problem go away (yes/no): n/a, it's in the replaygain plugin

Activity

  1. obethgeoff10c-ops commented on Nov 3, 2026

    @obethgeoff10c-ops

    Hi! I'd like to work on this issue and submit a pull request with a fix and regression test. I'll first verify the behavior on the current main branch. Please let me know if anyone is already working on it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    replaygain

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions