Use select statement to prevent blocking on context status check
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
1c623051ec
commit
ac7c626f56
@ -9,7 +9,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.elara.ws/infinitime"
|
"go.elara.ws/infinitime"
|
||||||
@ -86,10 +85,13 @@ func initWeather(ctx context.Context, wg WaitGroup, dev *infinitime.Device) erro
|
|||||||
go func() {
|
go func() {
|
||||||
defer wg.Done("weather")
|
defer wg.Done("weather")
|
||||||
for {
|
for {
|
||||||
_, ok := <-ctx.Done()
|
select {
|
||||||
|
case _, ok := <-ctx.Done():
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
// Attempt to get weather
|
// Attempt to get weather
|
||||||
data, err := getWeather(ctx, lat, lon)
|
data, err := getWeather(ctx, lat, lon)
|
||||||
|
Loading…
Reference in New Issue
Block a user