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
|
jobsCount := 0
|
||||||
|
|
||||||
for _, parser := range parsers {
|
for _, parser := range parsers {
|
||||||
if jobsCount < *workers {
|
for {
|
||||||
wg.Add(1)
|
if jobsCount < *workers {
|
||||||
jobsCount++
|
wg.Add(1)
|
||||||
go handleProducts(parser, notifiers, db, &wg)
|
jobsCount++
|
||||||
} else {
|
go handleProducts(parser, notifiers, db, &wg)
|
||||||
log.Debugf("waiting for intermediate jobs to end")
|
break
|
||||||
wg.Wait()
|
} else {
|
||||||
jobsCount = 0
|
log.Debugf("waiting for intermediate jobs to end")
|
||||||
|
wg.Wait()
|
||||||
|
jobsCount = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue