Add a timeout to background task
This commit is contained in:
@@ -99,7 +99,9 @@ func (e *externalMetadata) UpdateArtistInfo(ctx context.Context, id string, simi
|
|||||||
// If we have fresh info, just return it and trigger a refresh in the background
|
// If we have fresh info, just return it and trigger a refresh in the background
|
||||||
if time.Since(artist.ExternalInfoUpdatedAt) < consts.ArtistInfoTimeToLive {
|
if time.Since(artist.ExternalInfoUpdatedAt) < consts.ArtistInfoTimeToLive {
|
||||||
go func() {
|
go func() {
|
||||||
err := e.refreshArtistInfo(context.Background(), artist)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||||
|
defer cancel()
|
||||||
|
err := e.refreshArtistInfo(ctx, artist)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error refreshing ArtistInfo", "id", id, "name", artist.Name, err)
|
log.Error("Error refreshing ArtistInfo", "id", id, "name", artist.Name, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user