diff options
author | Rasmus Dahlberg <rasmus@rgdd.se> | 2023-04-02 15:10:34 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus@rgdd.se> | 2023-04-02 15:10:34 +0200 |
commit | 671f8e0fbbcb7194d5f59a6927f7752e86f6282c (patch) | |
tree | 9e358c4d3bc1d0bdaf7466823e1cbe3cf3784077 | |
parent | ecca93a9a27ba965ef592fd496d4b504da8628b0 (diff) |
Complete ongoing queries on ctrl+C
-rw-r--r-- | main.go | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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) } } }() |