forked from Elara6331/itd
Use select statement to prevent blocking on context status check
This commit is contained in:
parent
1c623051ec
commit
ac7c626f56
10
weather.go
10
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
|
||||
|
Loading…
Reference in New Issue
Block a user