Archived
1
0
Fork 0

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:
Julien Riou 2021-04-12 09:21:24 +02:00
parent e57a1c0148
commit 5ba0699adc
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7

19
main.go
View file

@ -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
}
}
}