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

View file

@ -197,16 +197,19 @@ func main() {
jobsCount := 0 jobsCount := 0
for _, parser := range parsers { for _, parser := range parsers {
for {
if jobsCount < *workers { if jobsCount < *workers {
wg.Add(1) wg.Add(1)
jobsCount++ jobsCount++
go handleProducts(parser, notifiers, db, &wg) go handleProducts(parser, notifiers, db, &wg)
break
} else { } else {
log.Debugf("waiting for intermediate jobs to end") log.Debugf("waiting for intermediate jobs to end")
wg.Wait() wg.Wait()
jobsCount = 0 jobsCount = 0
} }
} }
}
log.Debugf("waiting for all jobs to end") log.Debugf("waiting for all jobs to end")
wg.Wait() wg.Wait()