mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Patch a concurrent access problem
This commit is contained in:
@ -8,7 +8,7 @@ import (
|
||||
// corresponds to the last commit, and not the one when the file will be
|
||||
// commited
|
||||
|
||||
var _Commit = "38dcd98"
|
||||
var _Commit = "1c6ab1c"
|
||||
var _Version = "Release 4.4.0"
|
||||
|
||||
// Version returns the version of the obitools package.
|
||||
|
@ -174,12 +174,15 @@ func (sequence *BioSequence) StatsPlusOne(desc StatsOnDescription, toAdd *BioSeq
|
||||
|
||||
}
|
||||
|
||||
sequence.annot_lock.Lock()
|
||||
old, ok := stats[sval]
|
||||
if !ok {
|
||||
old = 0
|
||||
}
|
||||
|
||||
stats[sval] = old + desc.Weight(toAdd)
|
||||
sequence.annot_lock.Unlock()
|
||||
|
||||
sequence.SetAttribute(StatsOnSlotName(desc.Name), stats) // TODO: check if this is necessary
|
||||
return retval
|
||||
}
|
||||
@ -228,7 +231,9 @@ func (sequence *BioSequence) Merge(tomerge *BioSequence, na string, inplace bool
|
||||
smk := sequence.StatsOn(desc, na)
|
||||
mmk := tomerge.StatsOn(desc, na)
|
||||
|
||||
sequence.annot_lock.Lock()
|
||||
annotations[StatsOnSlotName(key)] = smk.Merge(mmk)
|
||||
sequence.annot_lock.Unlock()
|
||||
} else {
|
||||
sequence.StatsPlusOne(desc, tomerge, na)
|
||||
}
|
||||
|
Reference in New Issue
Block a user