mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-31 14:54:27 +00:00
handle context in process loop
Kubernetes-commit: f67d30b3529ea970dd5fd069eaddfc7f61d74169
This commit is contained in:
parent
660181394a
commit
03728c1ebe
16
tools/cache/controller.go
vendored
16
tools/cache/controller.go
vendored
@ -204,13 +204,15 @@ func (c *controller) LastSyncResourceVersion() string {
|
||||
// concurrently.
|
||||
func (c *controller) processLoop(ctx context.Context) {
|
||||
for {
|
||||
// TODO: Plumb through the ctx so that this can
|
||||
// actually exit when the controller is stopped. Or just give up on this stuff
|
||||
// ever being stoppable.
|
||||
_, err := c.config.Queue.Pop(PopProcessFunc(c.config.Process))
|
||||
if err != nil {
|
||||
if err == ErrFIFOClosed {
|
||||
return
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
_, err := c.config.Queue.Pop(PopProcessFunc(c.config.Process))
|
||||
if err != nil {
|
||||
if err == ErrFIFOClosed {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user