
The add-on code was copy-pasted from other addons and used the GPL v2 license, whereas by accident the LICENSE text file had the GNU "Affero" GPL license v3 (instead of regular GPL v3). This is now all streamlined, and all code is licensed as "GPL v3 or later". Furthermore, the code comments just show a SPDX License Identifier instead of an entire license block.
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package worker
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"git.blender.org/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 := log.With().Str("status", string(w.state)).Logger()
|
|
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):
|
|
newStatus := w.queryManagerForStateChange(ctx)
|
|
if newStatus != nil {
|
|
logger.Debug().Str("newStatus", string(*newStatus)).Msg("asleep state interrupted by state change")
|
|
w.changeState(ctx, *newStatus)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|