From ac7c626f562109a68310d64e604c8827704f213f Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Wed, 28 Jun 2023 21:49:07 -0700 Subject: [PATCH] Use select statement to prevent blocking on context status check --- weather.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/weather.go b/weather.go index 23ef3bb..ba11f69 100644 --- a/weather.go +++ b/weather.go @@ -9,7 +9,6 @@ import ( "net/url" "strconv" "strings" - "time" "go.elara.ws/infinitime" @@ -86,9 +85,12 @@ func initWeather(ctx context.Context, wg WaitGroup, dev *infinitime.Device) erro go func() { defer wg.Done("weather") for { - _, ok := <-ctx.Done() - if !ok { - return + select { + case _, ok := <-ctx.Done(): + if !ok { + return + } + default: } // Attempt to get weather