Worker: Avoid sleep at shutdown

Make the sleep between fetching tasks interruptable, so that a shutdown
doesn't have to wait a few seconds.
This commit is contained in:
Sybren A. Stüvel 2022-06-16 12:08:13 +02:00
parent 9ab41984ac
commit 5bc94101e8

View File

@ -90,7 +90,11 @@ func (w *Worker) runStateAwake(ctx context.Context) {
} }
// Do some rate limiting. This is mostly useful while developing. // Do some rate limiting. This is mostly useful while developing.
time.Sleep(durationTaskComplete) select {
case <-ctx.Done():
return
case <-time.After(durationTaskComplete):
}
} }
} }