aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@rgdd.se>2023-04-02 15:10:34 +0200
committerRasmus Dahlberg <rasmus@rgdd.se>2023-04-02 15:10:34 +0200
commit671f8e0fbbcb7194d5f59a6927f7752e86f6282c (patch)
tree9e358c4d3bc1d0bdaf7466823e1cbe3cf3784077
parentecca93a9a27ba965ef592fd496d4b504da8628b0 (diff)
Complete ongoing queries on ctrl+C
-rw-r--r--main.go5
1 files 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)
}
}
}()