From a54c4f52da38f0ac1d69ab148dccd94396bfa7a5 Mon Sep 17 00:00:00 2001 From: gregory <10611760+gregoryguillou@users.noreply.github.com> Date: Wed, 29 Jun 2022 12:13:06 +0200 Subject: [PATCH] unlock the engine in a case of an error --- engine.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine.go b/engine.go index 0948b5d..69906da 100644 --- a/engine.go +++ b/engine.go @@ -58,12 +58,10 @@ func (e *Engine) Start(ctx context.Context) { for { select { case <-e.ticker.C: - e.Lock() if err := e.process(ctx); err != nil { log.Err(err).Msg("Processing block.") return } - e.Unlock() case <-ctx.Done(): return @@ -98,6 +96,8 @@ func (e *Engine) Subscribe(ctx context.Context) { } func (e *Engine) process(ctx context.Context) error { + e.Lock() + defer e.Unlock() worker := make(chan concurrently.WorkFunction, concurrency) outputs := concurrently.Process(ctx, worker, &concurrently.Options{PoolSize: concurrency, OutChannelBuffer: concurrency})