Repository: beetbox/beets

Issue:
Replaygain: metadata doesn't get written to file on import with parallelized backends.
### Problem
If I import files with `replaygain: auto: yes` and any backend that has `do_parallel = True` replaygain values get calculated and saved in the db but not written to the files.
This seems to be introduced with: https://github.com/beetbox/beets/pull/3478

If I set `do_parallel = False` for the backend I'm using the metadata gets written as expected; setting `threads = 0` doesn't help.

### Setup

* OS: Slackware current (linux)
* Python version: 3.8.6
* beets version: git master (commit 48222153ae4b4409584085491a446ba972a45a07 from Dec 16, 2020 installed in a virtualenv)

### Results of some of my tests:

Running:

```sh
$ beet -vv -c /tmp/beetsTest/config.yaml import /tmp/beetsTest/music/todo/
```

with this config:
```YAML
library: /tmp/beetsTest/beets.db
directory: /tmp/beetsTest/music/done
plugins: [replaygain]
replaygain:
    auto: yes
    backend: command
```

printed this:
<details>
  <summary>click for full log</summary>

```
beet -vv -c /tmp/beetsTest/config.yaml import /tmp/beetsTest/music/todo/
overlaying configuration: /tmp/beetsTest/config.yaml
no user configuration found at /home/[redacted]/.config/beets/config.yaml
data directory: /home/[redacted]/.config/beets
plugin paths: 
Sending event: pluginload
library database: /tmp/beetsTest/beets.db
library directory: /tmp/beetsTest/music/done
Sending event: library_opened
Sending event: import_begin
Sending event: import_task_created
Sending event: import_task_start
Looking up: /tmp/beetsTest/music/todo/2008 - Occidente
Tagging Rein - Occidente
No album ID found.
Search terms: Rein - Occidente
Album might be VA: False
Searching for MusicBrainz releases with: {'release': 'occidente', 'artist': 'rein', 'tracks': '20'}
Requesting MusicBrainz release 3f68a1bf-810e-4c38-bf3e-7261373e347f
primary MB release type: album
Sending event: albuminfo_received
Candidate: Rein - Occidente (3f68a1bf-810e-4c38-bf3e-7261373e347f)
Computing track assignment...
...done.
Success. Distance: 0.00
Requesting MusicBrainz release f582c8c5-e9b4-4f82-aebb-80ef23b64b2f
primary MB release type: album
Sending event: albuminfo_received
Candidate: Rein - Occidente (f582c8c5-e9b4-4f82-aebb-80ef23b64b2f)
Computing track assignment...
...done.
Success. Distance: 0.01
Requesting MusicBrainz release f16a971f-7024-42ef-a50c-9a098d805454
primary MB release type: album
Sending event: albuminfo_received
Candidate: Décadence Culture - Occidente (f16a971f-7024-42ef-a50c-9a098d805454)
Computing track assignment...
...done.
Success. Distance: 0.65
Requesting MusicBrainz release bb4d0b05-044f-4401-819a-76b7a3e21276
primary MB release type: ep
Sending event: albuminfo_received
Candidate: Amor Elefante - Occidente (bb4d0b05-044f-4401-819a-76b7a3e21276)
Computing track assignment...
...done.
Success. Distance: 0.69
Requesting MusicBrainz release dd20055e-3fb2-44ec-925d-5752e9f052b5
primary MB release type: album
Sending event: albuminfo_received
Candidate: Francesco Messina - Medio occidente (dd20055e-3fb2-44ec-925d-5752e9f052b5)
Computing track assignment...
...done.
Success. Distance: 0.64
Evaluating 5 candidates.

/tmp/beetsTest/music/todo/2008 - Occidente (20 items)
Sending event: before_choose_candidate
Tagging:
    Rein - Occidente
URL:
    https://musicbrainz.org/release/3f68a1bf-810e-4c38-bf3e-7261373e347f
(Similarity: 100.0%) (Digital Media, 2008, XW, Jamendo, 26737)
 * 150 Sprint Veloce                -> 150 sprint veloce
 * Canzone dell'Irlanda Occidentale -> Canzone dell'Irlanda occidentale
Sending event: import_task_choice
Sending event: import_task_apply
0 of 20 items replaced
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
replaygain: analyzing Rein - Occidente
replaygain: analyzing 20 files
replaygain: executing mp3gain -o -s s -k -d 0 /tmp/beetsTest/music/todo/2008 - Occidente/01 - Occidente.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/02 - Sud (#2).mp3 /tmp/beetsTest/music/todo/2008 - Occidente/03 - 150 Sprint Veloce.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/04 - Il deserto di Piero.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/05 - La canzone di Diana.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/06 - Est.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/07 - 4 e mezza.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/08 - Settembre (#3).mp3 /tmp/beetsTest/music/todo/2008 - Occidente/09 - Il ponte di Mostar.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/10 - Genova.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/11 - Grandtour.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/12 - Canzone dell'Irlanda Occidentale.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/13 - Boulevard Montvert.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/14 - Verso San Paolo.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/15 - Sud America.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/16 - Discorsi a vapore.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/17 - I tram di Roma.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/18 - Il ventesimo giorno.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/19 - Il ricordo delle tue mani.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/20 - L'epilogo.mp3
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: import_task_files
Sending event: album_imported
Sending event: import
replaygain: analysis finished
Sending event: database_change
replaygain: applied track gain -7.43 LU, peak 1.0611455440673827 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Occidente
Sending event: database_change
replaygain: applied track gain -8.55 LU, peak 1.081569075592041 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Sud (#2)
Sending event: database_change
replaygain: applied track gain -8.59 LU, peak 1.1010917425231934 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - 150 sprint veloce
Sending event: database_change
replaygain: applied track gain -6.99 LU, peak 1.1057721376342773 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Il deserto di Piero
Sending event: database_change
replaygain: applied track gain -5.26 LU, peak 1.0462921857910157 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - La canzone di Diana
Sending event: database_change
replaygain: applied track gain -9.18 LU, peak 1.1384513378295897 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Est
Sending event: database_change
replaygain: applied track gain -6.27 LU, peak 1.0573697090148926 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - 4 e mezza
Sending event: database_change
replaygain: applied track gain -7.77 LU, peak 1.0880013704223632 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Settembre (#3)
Sending event: database_change
replaygain: applied track gain -8.16 LU, peak 1.0979830026550292 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Il ponte di Mostar
Sending event: database_change
replaygain: applied track gain -6.97 LU, peak 1.1099706888122558 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Genova
Sending event: database_change
replaygain: applied track gain -9.54 LU, peak 1.1197123527526855 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Grandtour
Sending event: database_change
replaygain: applied track gain -8.79 LU, peak 1.121659755706787 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Canzone dell'Irlanda occidentale
Sending event: database_change
replaygain: applied track gain -6.99 LU, peak 1.0953476428833009 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Boulevard Montvert
Sending event: database_change
replaygain: applied track gain -7.19 LU, peak 1.1417335271911622 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Verso San Paolo
Sending event: database_change
replaygain: applied track gain -8.04 LU, peak 1.0737806558532714 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Sud America
Sending event: database_change
replaygain: applied track gain -7.6 LU, peak 1.1297643184814452 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Discorsi a vapore
Sending event: database_change
replaygain: applied track gain -8.46 LU, peak 1.0834281444702147 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - I tram di Roma
Sending event: database_change
replaygain: applied track gain -8.55 LU, peak 1.0834854841308594 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Il ventesimo giorno
Sending event: database_change
replaygain: applied track gain -2.35 LU, peak 0.6327679157104492 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Il ricordo delle tue mani
Sending event: database_change
replaygain: applied track gain -7.98 LU, peak 1.1390141248779297 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - L'epilogo
Sending event: cli_exit
```

</details>


This gives me files with these id3 tags:

```
$ mid3v2 01*.mp3

IDv2 tag info for 01 Occidente.mp3
APIC=cover front, Rein : Occidente (image/jpg, 39765 bytes)
APIC=lyricist, http://www.jamendo.com (image/png, 6889 bytes)
APIC=other, http://creativecommons.org/licenses/by-nc-nd/2.5/it/ (image/png, 5281 bytes)
TALB=Occidente
TBPM=0
TCMP=0
TCON=Blues
TDEN=2008-06-12
TDOR=2008-05-03
TDRC=2008-06-13
TIPL=[unrepresentable data]
TIT2=Occidente
TLAN=ita
TLEN=210000
TMED=Digital Media
TOFN= - Occidente.mp3
TPE1=Rein
TPE2=Rein
TPOS=1/1
TPUB=Jamendo
TRCK=1/20
TSOP=Rein
TXXX=ALBUMARTISTSORT=Rein
TXXX=Album Artist Credit=Rein
TXXX=Artist Credit=Rein
TXXX=CATALOGNUMBER=26737
TXXX=MusicBrainz Album Artist Id=20bf0e88-c49d-4bcd-b3d9-61cff97f29d8
TXXX=MusicBrainz Album Id=3f68a1bf-810e-4c38-bf3e-7261373e347f
TXXX=MusicBrainz Album Release Country=XW
TXXX=MusicBrainz Album Status=Official
TXXX=MusicBrainz Album Type=album
TXXX=MusicBrainz Artist Id=20bf0e88-c49d-4bcd-b3d9-61cff97f29d8
TXXX=MusicBrainz Release Group Id=59f2ab57-e144-32db-88d5-b52ca4af9eb3
TXXX=MusicBrainz Release Track Id=c7269ba8-69e7-342c-b5b2-3acc8ac09c02
TXXX=Script=Latn
UFID=http://musicbrainz.org=b'baec891b-ffe0-4e15-a092-9988d81bc761'
UFID=jamendo.com/track/179569=b''
USLT==XXX=
```
I can then execute
```
$ beet -vv -c /tmp/beetsTest/config.yaml write Occidente
```
<details>
  <summary>click for full log</summary>

```
overlaying configuration: /tmp/beetsTest/config.yaml
no user configuration found at /home/[redacted]/.config/beets/config.yaml
data directory: /home/[redacted]/.config/beets
plugin paths: 
Sending event: pluginload
library database: /tmp/beetsTest/beets.db
library directory: /tmp/beetsTest/music/done
Sending event: library_opened
Rein - Occidente - Occidente
  rg_track_gain: 0.0 -> -7.4
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Sud (#2)
  rg_track_gain: 0.0 -> -8.6
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - 150 sprint veloce
  rg_track_gain: 0.0 -> -8.6
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Il deserto di Piero
  rg_track_gain: 0.0 -> -7.0
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - La canzone di Diana
  rg_track_gain: 0.0 -> -5.3
  rg_track_peak: 0.0 -> 1.0
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Est
  rg_track_gain: 0.0 -> -9.2
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - 4 e mezza
  rg_track_gain: 0.0 -> -6.3
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Settembre (#3)
  rg_track_gain: 0.0 -> -7.8
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Il ponte di Mostar
  rg_track_gain: 0.0 -> -8.2
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Genova
  rg_track_gain: 0.0 -> -7.0
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Grandtour
  rg_track_gain: 0.0 -> -9.5
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Canzone dell'Irlanda occidentale
  rg_track_gain: 0.0 -> -8.8
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Boulevard Montvert
  rg_track_gain: 0.0 -> -7.0
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Verso San Paolo
  rg_track_gain: 0.0 -> -7.2
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Sud America
  rg_track_gain: 0.0 -> -8.0
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Discorsi a vapore
  rg_track_gain: 0.0 -> -7.6
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - I tram di Roma
  rg_track_gain: 0.0 -> -8.5
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Il ventesimo giorno
  rg_track_gain: 0.0 -> -8.6
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - Il ricordo delle tue mani
  rg_track_gain: 0.0 -> -2.4
  rg_track_peak: 0.0 -> 0.6
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Rein - Occidente - L'epilogo
  rg_track_gain: 0.0 -> -8.0
  rg_track_peak: 0.0 -> 1.1
  rg_album_gain: 0.0 -> -8.2
  rg_album_peak: 0.0 -> 1.1
Sending event: write
Sending event: after_write
Sending event: database_change
Sending event: cli_exit
```
</details>

The result is files like this:
```
$ mid3v2 01*.mp3

IDv2 tag info for 01 Occidente.mp3
APIC=cover front, Rein : Occidente (image/jpg, 39765 bytes)
APIC=lyricist, http://www.jamendo.com (image/png, 6889 bytes)
APIC=other, http://creativecommons.org/licenses/by-nc-nd/2.5/it/ (image/png, 5281 bytes)
COMM=iTunNORM=eng= 0000159E 0000159E 0000360A 0000360A 00000000 00000000 000087D3 000087D3 00000000 00000000
TALB=Occidente
TBPM=0
TCMP=0
TCON=Blues
TDEN=2008-06-12
TDOR=2008-05-03
TDRC=2008-06-13
TIPL=[unrepresentable data]
TIT2=Occidente
TLAN=ita
TLEN=210000
TMED=Digital Media
TOFN= - Occidente.mp3
TPE1=Rein
TPE2=Rein
TPOS=1/1
TPUB=Jamendo
TRCK=1/20
TSOP=Rein
TXXX=ALBUMARTISTSORT=Rein
TXXX=Album Artist Credit=Rein
TXXX=Artist Credit=Rein
TXXX=CATALOGNUMBER=26737
TXXX=MusicBrainz Album Artist Id=20bf0e88-c49d-4bcd-b3d9-61cff97f29d8
TXXX=MusicBrainz Album Id=3f68a1bf-810e-4c38-bf3e-7261373e347f
TXXX=MusicBrainz Album Release Country=XW
TXXX=MusicBrainz Album Status=Official
TXXX=MusicBrainz Album Type=album
TXXX=MusicBrainz Artist Id=20bf0e88-c49d-4bcd-b3d9-61cff97f29d8
TXXX=MusicBrainz Release Group Id=59f2ab57-e144-32db-88d5-b52ca4af9eb3
TXXX=MusicBrainz Release Track Id=c7269ba8-69e7-342c-b5b2-3acc8ac09c02
TXXX=REPLAYGAIN_ALBUM_GAIN=-8.17 dB
TXXX=REPLAYGAIN_ALBUM_PEAK=1.141734
TXXX=REPLAYGAIN_TRACK_GAIN=-7.43 dB
TXXX=REPLAYGAIN_TRACK_PEAK=1.061146
TXXX=Script=Latn
UFID=http://musicbrainz.org=b'baec891b-ffe0-4e15-a092-9988d81bc761'
UFID=jamendo.com/track/179569=b''
USLT==XXX=
```



If I modify beetsplug/replaygain.py thus:
```
--- replaygain.py	2020-12-19 22:21:57.379579391 +0100
+++ replaygain.py_	2020-12-19 22:21:18.627580000 +0100
@@ -631,7 +631,7 @@
 
 # mpgain/aacgain CLI tool backend.
 class CommandBackend(Backend):
-    do_parallel = True
+    do_parallel = False
 
     def __init__(self, config, log):
         super(CommandBackend, self).__init__(config, log)
```
The resulting files are ok.

<details>
  <summary>click for more details</summary>

```
$  beet -vv -c /tmp/beetsTest/config.yaml import /tmp/beetsTest/music/todo/

overlaying configuration: /tmp/beetsTest/config.yaml
no user configuration found at /home/skapazzo/.config/beets/config.yaml
data directory: /home/skapazzo/.config/beets
plugin paths: 
Sending event: pluginload
library database: /tmp/beetsTest/beets.db
library directory: /tmp/beetsTest/music/done
Sending event: library_opened
Sending event: import_begin
Sending event: import_task_created
Sending event: import_task_start
Looking up: /tmp/beetsTest/music/todo/2008 - Occidente
Tagging Rein - Occidente
No album ID found.
Search terms: Rein - Occidente
Album might be VA: False
Searching for MusicBrainz releases with: {'release': 'occidente', 'artist': 'rein', 'tracks': '20'}
Requesting MusicBrainz release 3f68a1bf-810e-4c38-bf3e-7261373e347f
primary MB release type: album
Sending event: albuminfo_received
Candidate: Rein - Occidente (3f68a1bf-810e-4c38-bf3e-7261373e347f)
Computing track assignment...
...done.
Success. Distance: 0.00
Requesting MusicBrainz release f582c8c5-e9b4-4f82-aebb-80ef23b64b2f
primary MB release type: album
Sending event: albuminfo_received
Candidate: Rein - Occidente (f582c8c5-e9b4-4f82-aebb-80ef23b64b2f)
Computing track assignment...
...done.
Success. Distance: 0.01
Requesting MusicBrainz release f16a971f-7024-42ef-a50c-9a098d805454
primary MB release type: album
Sending event: albuminfo_received
Candidate: Décadence Culture - Occidente (f16a971f-7024-42ef-a50c-9a098d805454)
Computing track assignment...
...done.
Success. Distance: 0.65
Requesting MusicBrainz release bb4d0b05-044f-4401-819a-76b7a3e21276
primary MB release type: ep
Sending event: albuminfo_received
Candidate: Amor Elefante - Occidente (bb4d0b05-044f-4401-819a-76b7a3e21276)
Computing track assignment...
...done.
Success. Distance: 0.69
Requesting MusicBrainz release dd20055e-3fb2-44ec-925d-5752e9f052b5
primary MB release type: album
Sending event: albuminfo_received
Candidate: Francesco Messina - Medio occidente (dd20055e-3fb2-44ec-925d-5752e9f052b5)
Computing track assignment...
...done.
Success. Distance: 0.64
Evaluating 5 candidates.

/tmp/beetsTest/music/todo/2008 - Occidente (20 items)
Sending event: before_choose_candidate
Tagging:
    Rein - Occidente
URL:
    https://musicbrainz.org/release/3f68a1bf-810e-4c38-bf3e-7261373e347f
(Similarity: 100.0%) (Digital Media, 2008, XW, Jamendo, 26737)
 * 150 Sprint Veloce                -> 150 sprint veloce
 * Canzone dell'Irlanda Occidentale -> Canzone dell'Irlanda occidentale
Sending event: import_task_choice
Sending event: import_task_apply
0 of 20 items replaced
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
replaygain: analyzing Rein - Occidente
replaygain: analyzing 20 files
replaygain: executing mp3gain -o -s s -k -d 0 /tmp/beetsTest/music/todo/2008 - Occidente/01 - Occidente.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/02 - Sud (#2).mp3 /tmp/beetsTest/music/todo/2008 - Occidente/03 - 150 Sprint Veloce.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/04 - Il deserto di Piero.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/05 - La canzone di Diana.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/06 - Est.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/07 - 4 e mezza.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/08 - Settembre (#3).mp3 /tmp/beetsTest/music/todo/2008 - Occidente/09 - Il ponte di Mostar.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/10 - Genova.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/11 - Grandtour.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/12 - Canzone dell'Irlanda Occidentale.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/13 - Boulevard Montvert.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/14 - Verso San Paolo.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/15 - Sud America.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/16 - Discorsi a vapore.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/17 - I tram di Roma.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/18 - Il ventesimo giorno.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/19 - Il ricordo delle tue mani.mp3 /tmp/beetsTest/music/todo/2008 - Occidente/20 - L'epilogo.mp3
replaygain: analysis finished
Sending event: database_change
replaygain: applied track gain -7.43 LU, peak 1.0611455440673827 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Occidente
Sending event: database_change
replaygain: applied track gain -8.55 LU, peak 1.081569075592041 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Sud (#2)
Sending event: database_change
replaygain: applied track gain -8.59 LU, peak 1.1010917425231934 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - 150 sprint veloce
Sending event: database_change
replaygain: applied track gain -6.99 LU, peak 1.1057721376342773 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Il deserto di Piero
Sending event: database_change
replaygain: applied track gain -5.26 LU, peak 1.0462921857910157 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - La canzone di Diana
Sending event: database_change
replaygain: applied track gain -9.18 LU, peak 1.1384513378295897 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Est
Sending event: database_change
replaygain: applied track gain -6.27 LU, peak 1.0573697090148926 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - 4 e mezza
Sending event: database_change
replaygain: applied track gain -7.77 LU, peak 1.0880013704223632 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Settembre (#3)
Sending event: database_change
replaygain: applied track gain -8.16 LU, peak 1.0979830026550292 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Il ponte di Mostar
Sending event: database_change
replaygain: applied track gain -6.97 LU, peak 1.1099706888122558 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Genova
Sending event: database_change
replaygain: applied track gain -9.54 LU, peak 1.1197123527526855 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Grandtour
Sending event: database_change
replaygain: applied track gain -8.79 LU, peak 1.121659755706787 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Canzone dell'Irlanda occidentale
Sending event: database_change
replaygain: applied track gain -6.99 LU, peak 1.0953476428833009 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Boulevard Montvert
Sending event: database_change
replaygain: applied track gain -7.19 LU, peak 1.1417335271911622 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Verso San Paolo
Sending event: database_change
replaygain: applied track gain -8.04 LU, peak 1.0737806558532714 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Sud America
Sending event: database_change
replaygain: applied track gain -7.6 LU, peak 1.1297643184814452 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Discorsi a vapore
Sending event: database_change
replaygain: applied track gain -8.46 LU, peak 1.0834281444702147 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - I tram di Roma
Sending event: database_change
replaygain: applied track gain -8.55 LU, peak 1.0834854841308594 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Il ventesimo giorno
Sending event: database_change
replaygain: applied track gain -2.35 LU, peak 0.6327679157104492 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - Il ricordo delle tue mani
Sending event: database_change
replaygain: applied track gain -7.98 LU, peak 1.1390141248779297 of FS
Sending event: database_change
replaygain: applied album gain -8.17 LU, peak 1.1417335271911622 of FS
replaygain: done analyzing Rein - Occidente - L'epilogo
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: import_task_files
Sending event: album_imported
Sending event: import
Sending event: cli_exit
```

</details>

If instead I use a backend without parallelization `backend: gstreamer` the resulting files are also ok:

<details>
  <summary>click for more details</summary>

```
$ beet -vv -c /tmp/beetsTest/config.yaml import /tmp/beetsTest/music/todo/

overlaying configuration: /tmp/beetsTest/config.yaml
no user configuration found at /home/[redacted]/.config/beets/config.yaml
data directory: /home/[redacted]/.config/beets
plugin paths: 
Sending event: pluginload
library database: /tmp/beetsTest/beets.db
library directory: /tmp/beetsTest/music/done
Sending event: library_opened
Sending event: import_begin
Sending event: import_task_created
Sending event: import_task_start
Looking up: /tmp/beetsTest/music/todo/2008 - Occidente
Tagging Rein - Occidente
No album ID found.
Search terms: Rein - Occidente
Album might be VA: False
Searching for MusicBrainz releases with: {'release': 'occidente', 'artist': 'rein', 'tracks': '20'}
Requesting MusicBrainz release 3f68a1bf-810e-4c38-bf3e-7261373e347f
primary MB release type: album
Sending event: albuminfo_received
Candidate: Rein - Occidente (3f68a1bf-810e-4c38-bf3e-7261373e347f)
Computing track assignment...
...done.
Success. Distance: 0.00
Requesting MusicBrainz release f582c8c5-e9b4-4f82-aebb-80ef23b64b2f
primary MB release type: album
Sending event: albuminfo_received
Candidate: Rein - Occidente (f582c8c5-e9b4-4f82-aebb-80ef23b64b2f)
Computing track assignment...
...done.
Success. Distance: 0.01
Requesting MusicBrainz release bb4d0b05-044f-4401-819a-76b7a3e21276
primary MB release type: ep
Sending event: albuminfo_received
Candidate: Amor Elefante - Occidente (bb4d0b05-044f-4401-819a-76b7a3e21276)
Computing track assignment...
...done.
Success. Distance: 0.69
Requesting MusicBrainz release f16a971f-7024-42ef-a50c-9a098d805454
primary MB release type: album
Sending event: albuminfo_received
Candidate: Décadence Culture - Occidente (f16a971f-7024-42ef-a50c-9a098d805454)
Computing track assignment...
...done.
Success. Distance: 0.65
Requesting MusicBrainz release dd20055e-3fb2-44ec-925d-5752e9f052b5
primary MB release type: album
Sending event: albuminfo_received
Candidate: Francesco Messina - Medio occidente (dd20055e-3fb2-44ec-925d-5752e9f052b5)
Computing track assignment...
...done.
Success. Distance: 0.64
Evaluating 5 candidates.

/tmp/beetsTest/music/todo/2008 - Occidente (20 items)
Sending event: before_choose_candidate
Tagging:
    Rein - Occidente
URL:
    https://musicbrainz.org/release/3f68a1bf-810e-4c38-bf3e-7261373e347f
(Similarity: 100.0%) (Digital Media, 2008, XW, Jamendo, 26737)
 * 150 Sprint Veloce                -> 150 sprint veloce
 * Canzone dell'Irlanda Occidentale -> Canzone dell'Irlanda occidentale
Sending event: import_task_choice
Sending event: import_task_apply
0 of 20 items replaced
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
replaygain: analyzing Rein - Occidente
Sending event: database_change
replaygain: applied track gain -7.440000000000012 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Occidente
Sending event: database_change
replaygain: applied track gain -8.600000000000009 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Sud (#2)
Sending event: database_change
replaygain: applied track gain -8.540000000000006 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - 150 sprint veloce
Sending event: database_change
replaygain: applied track gain -7.0 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Il deserto di Piero
Sending event: database_change
replaygain: applied track gain -5.310000000000002 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - La canzone di Diana
Sending event: database_change
replaygain: applied track gain -9.190000000000012 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Est
Sending event: database_change
replaygain: applied track gain -6.300000000000011 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - 4 e mezza
Sending event: database_change
replaygain: applied track gain -7.790000000000006 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Settembre (#3)
Sending event: database_change
replaygain: applied track gain -8.110000000000014 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Il ponte di Mostar
Sending event: database_change
replaygain: applied track gain -6.970000000000013 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Genova
Sending event: database_change
replaygain: applied track gain -9.52000000000001 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Grandtour
Sending event: database_change
replaygain: applied track gain -8.800000000000011 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Canzone dell'Irlanda occidentale
Sending event: database_change
replaygain: applied track gain -6.960000000000008 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Boulevard Montvert
Sending event: database_change
replaygain: applied track gain -7.240000000000009 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Verso San Paolo
Sending event: database_change
replaygain: applied track gain -8.02000000000001 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Sud America
Sending event: database_change
replaygain: applied track gain -7.5800000000000125 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Discorsi a vapore
Sending event: database_change
replaygain: applied track gain -8.420000000000002 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - I tram di Roma
Sending event: database_change
replaygain: applied track gain -8.580000000000013 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Il ventesimo giorno
Sending event: database_change
replaygain: applied track gain -2.3000000000000114 LU, peak 0.632781982421875 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - Il ricordo delle tue mani
Sending event: database_change
replaygain: applied track gain -7.950000000000003 LU, peak 1.0 of FS
Sending event: database_change
replaygain: applied album gain -7.950000000000003 LU, peak 1.0 of FS
replaygain: done analyzing Rein - Occidente - L'epilogo
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: item_copied
Sending event: database_change
Sending event: database_change
Sending event: write
Sending event: after_write
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: database_change
Sending event: import_task_files
Sending event: album_imported
Sending event: import
Sending event: cli_exit

```

I get these results:

```
$ mid3v2 01*.mp3

IDv2 tag info for 01 Occidente.mp3
APIC=cover front, Rein : Occidente (image/jpg, 39765 bytes)
APIC=lyricist, http://www.jamendo.com (image/png, 6889 bytes)
APIC=other, http://creativecommons.org/licenses/by-nc-nd/2.5/it/ (image/png, 5281 bytes)
COMM=iTunNORM=eng= 000015AA 000015AA 0000362A 0000362A 00000000 00000000 00008000 00008000 00000000 00000000
TALB=Occidente
TBPM=0
TCMP=0
TCON=Blues
TDEN=2008-06-12
TDOR=2008-05-03
TDRC=2008-06-13
TIPL=[unrepresentable data]
TIT2=Occidente
TLAN=ita
TLEN=210000
TMED=Digital Media
TOFN= - Occidente.mp3
TPE1=Rein
TPE2=Rein
TPOS=1/1
TPUB=Jamendo
TRCK=1/20
TSOP=Rein
TXXX=ALBUMARTISTSORT=Rein
TXXX=Album Artist Credit=Rein
TXXX=Artist Credit=Rein
TXXX=CATALOGNUMBER=26737
TXXX=MusicBrainz Album Artist Id=20bf0e88-c49d-4bcd-b3d9-61cff97f29d8
TXXX=MusicBrainz Album Id=3f68a1bf-810e-4c38-bf3e-7261373e347f
TXXX=MusicBrainz Album Release Country=XW
TXXX=MusicBrainz Album Status=Official
TXXX=MusicBrainz Album Type=album
TXXX=MusicBrainz Artist Id=20bf0e88-c49d-4bcd-b3d9-61cff97f29d8
TXXX=MusicBrainz Release Group Id=59f2ab57-e144-32db-88d5-b52ca4af9eb3
TXXX=MusicBrainz Release Track Id=c7269ba8-69e7-342c-b5b2-3acc8ac09c02
TXXX=REPLAYGAIN_ALBUM_GAIN=-7.95 dB
TXXX=REPLAYGAIN_ALBUM_PEAK=1.000000
TXXX=REPLAYGAIN_TRACK_GAIN=-7.44 dB
TXXX=REPLAYGAIN_TRACK_PEAK=1.000000
TXXX=Script=Latn
UFID=http://musicbrainz.org=b'baec891b-ffe0-4e15-a092-9988d81bc761'
UFID=jamendo.com/track/179569=b''
USLT==XXX=
```
</details>

In my everyday beets where I discovered this problem I confirmed that the replaygain is in the db with the inline plugin, in this testing environment I just checked inside the db file.

My configuration (output of `beet config`) is:

```yaml
library: /tmp/beetsTest/beets.db
directory: /tmp/beetsTest/music/done

plugins: [replaygain]
replaygain:
    auto: yes
    backend: command
    overwrite: no
    threads: 4
    per_disc: no
    peak: 'true'
    targetlevel: 89
    r128: [Opus]
    r128_targetlevel: 84
    command: ''
    noclip: yes
```


Discussion:
Thanks, this doesn't look too good :open_mouth: 
I'll be checking it out, keep you posted!

Resolving patch:
diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py
--- a/beetsplug/replaygain.py
+++ b/beetsplug/replaygain.py
@@ -1553,7 +1553,8 @@ def close_pool(self):
     def import_begin(self, session):
         """Handle `import_begin` event -> open pool
         """
-        self.open_pool(self.config['threads'].get(int))
+        if self.config['auto']:
+            self.open_pool(self.config['threads'].get(int))
 
     def import_end(self, paths):
         """Handle `import` event -> close pool
@@ -1563,10 +1564,19 @@ def import_end(self, paths):
     def imported(self, session, task):
         """Add replay gain info to items or albums of ``task``.
         """
-        if task.is_album:
-            self.handle_album(task.album, False)
-        else:
-            self.handle_track(task.item, False)
+        if self.config['auto']:
+            if task.is_album:
+                self.handle_album(
+                    task.album,
+                    self.config['auto'].get(bool),
+                    self.config['overwrite'].get(bool)
+                )
+            else:
+                self.handle_track(
+                    task.item,
+                    self.config['auto'].get(bool),
+                    self.config['overwrite'].get(bool)
+                )
 
     def commands(self):
         """Return the "replaygain" ui subcommand.


Test patch: