Bugfix asynchronous loop
When workers threshold was reached, the current parser was skipped instead of being processed later. Adding a for loop to retry instead. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
e57a1c0148
commit
5ba0699adc
1 changed files with 11 additions and 8 deletions
19
main.go
19
main.go
|
@ -197,14 +197,17 @@ func main() {
|
|||
jobsCount := 0
|
||||
|
||||
for _, parser := range parsers {
|
||||
if jobsCount < *workers {
|
||||
wg.Add(1)
|
||||
jobsCount++
|
||||
go handleProducts(parser, notifiers, db, &wg)
|
||||
} else {
|
||||
log.Debugf("waiting for intermediate jobs to end")
|
||||
wg.Wait()
|
||||
jobsCount = 0
|
||||
for {
|
||||
if jobsCount < *workers {
|
||||
wg.Add(1)
|
||||
jobsCount++
|
||||
go handleProducts(parser, notifiers, db, &wg)
|
||||
break
|
||||
} else {
|
||||
log.Debugf("waiting for intermediate jobs to end")
|
||||
wg.Wait()
|
||||
jobsCount = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue