From 312aa37b99a867e8b476d590447913bde4e99d9a Mon Sep 17 00:00:00 2001 From: Fergal Gribben Date: Wed, 18 Oct 2023 00:41:24 +0100 Subject: [PATCH] Use threadctrl to avail of context cancellation but still rely on a wait group to blocl until the lookups finish --- .../ocr2/plugins/ocr2keeper/evm21/streams_lookup.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/services/ocr2/plugins/ocr2keeper/evm21/streams_lookup.go b/core/services/ocr2/plugins/ocr2keeper/evm21/streams_lookup.go index 4c14efeddb7..20abaca3b6c 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evm21/streams_lookup.go +++ b/core/services/ocr2/plugins/ocr2keeper/evm21/streams_lookup.go @@ -148,10 +148,14 @@ func (r *EvmRegistry) streamsLookup(ctx context.Context, checkResults []ocr2keep } var wg sync.WaitGroup - for i, lookup := range lookups { - wg.Add(1) - go r.doLookup(ctx, &wg, lookup, i, checkResults, lggr) - } + wg.Add(len(lookups)) + + r.threadCtrl.Go(func(ctx context.Context) { + for i, lookup := range lookups { + go r.doLookup(ctx, &wg, lookup, i, checkResults, lggr) + } + }) + wg.Wait() // don't surface error to plugin bc StreamsLookup process should be self-contained.