From 671f8e0fbbcb7194d5f59a6927f7752e86f6282c Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sun, 2 Apr 2023 15:10:34 +0200 Subject: Complete ongoing queries on ctrl+C --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 726da75..88260bf 100644 --- a/main.go +++ b/main.go @@ -44,7 +44,8 @@ func main() { var wg sync.WaitGroup defer wg.Wait() - ctx, cancel := context.WithCancel(context.Background()) + bg := context.Background() + ctx, cancel := context.WithCancel(bg) defer cancel() start := time.Now().Round(time.Second) @@ -70,7 +71,7 @@ func main() { case <-ctx.Done(): return case question := <-questionCh: - work(ctx, cli, opts.Timeout, question, answerCh) + work(bg, cli, opts.Timeout, question, answerCh) } } }() -- cgit v1.2.3