flamenco/internal/worker/state_asleep.go
Sybren A. Stüvel 02fac6a4df Change Go package name from git.blender.org to projects.blender.org
Change the package base name of the Go code, from
`git.blender.org/flamenco` to `projects.blender.org/studio/flamenco`.

The old location, `git.blender.org`, has no longer been use since the
[migration to Gitea][1]. The new package names now reflect the actual
location where Flamenco is hosted.

[1]: https://code.blender.org/2023/02/new-blender-development-infrastructure/
2023-08-01 12:42:31 +02:00

44 lines
867 B
Go

package worker
// SPDX-License-Identifier: GPL-3.0-or-later
import (
"context"
"time"
"projects.blender.org/studio/flamenco/pkg/api"
)
const durationSleepCheck = 3 * time.Second
func (w *Worker) gotoStateAsleep(ctx context.Context) {
w.stateMutex.Lock()
defer w.stateMutex.Unlock()
w.state = api.WorkerStatusAsleep
w.doneWg.Add(2)
w.ackStateChange(ctx, w.state)
go w.runStateAsleep(ctx)
}
func (w *Worker) runStateAsleep(ctx context.Context) {
defer w.doneWg.Done()
logger := w.loggerWithStatus()
logger.Info().Msg("sleeping")
for {
select {
case <-ctx.Done():
logger.Debug().Msg("asleep state interrupted by context cancellation")
return
case <-w.doneChan:
logger.Debug().Msg("asleep state interrupted by shutdown")
return
case <-time.After(durationSleepCheck):
if w.changeStateIfRequested(ctx) {
return
}
}
}
}