Do not continue if semaphore can't be acquired (#49)

This commit is contained in:
Bill Rich 2022-02-17 12:45:54 -08:00 committed by Dustin Decker
parent 30034f5d28
commit c742f6a816

View file

@ -293,7 +293,10 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
errs := []error{}
var errsMut sync.Mutex
for i, repoURL := range s.repos {
s.jobSem.Acquire(ctx, 1)
if err := s.jobSem.Acquire(ctx, 1); err != nil {
log.WithError(err).Debug("could not acquire semaphore")
continue
}
wg.Add(1)
go func(ctx context.Context, repoURL string, i int) {
defer s.jobSem.Release(1)