From eb2e58baeb7984b34e77efcb3a1b499eff186ad4 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sun, 2 Apr 2023 15:12:54 +0200 Subject: Move warning print --- main.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 88260bf..830af03 100644 --- a/main.go +++ b/main.go @@ -86,9 +86,6 @@ func main() { log.Printf("INFO: starting work generator\n") workGenerator(ctx, opts, fp, questionCh) - if err := ctx.Err(); err != nil { - log.Printf("WARNING: premature shutdown (context cancelled)\n") - } } func await(ctx context.Context, cancel context.CancelFunc) { @@ -98,10 +95,10 @@ func await(ctx context.Context, cancel context.CancelFunc) { signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) select { case <-sigs: + log.Printf("WARNING: premature shutdown (context cancelled)\n") + cancel() case <-ctx.Done(): } - - cancel() } func work(ctx context.Context, cli *http.Client, timeout time.Duration, question qna.Question, answerCh chan qna.Answer) { -- cgit v1.2.3