Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
wrap time.Sleep in select
Browse files Browse the repository at this point in the history
  • Loading branch information
glorv committed Oct 19, 2020
1 parent 57113da commit a4459f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lightning/backend/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,11 @@ func (local *local) isIngestRetryable(
}
log.L().Warn("get region by key return nil, will retry", zap.Reflect("region", region),
zap.Int("retry", i))
time.Sleep(time.Second)
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-time.After(time.Second):
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions lightning/backend/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ func (s *localSuite) TestNextKey(c *C) {
c.Assert(nextKey([]byte{}), DeepEquals, []byte{})

cases := [][]byte{
[]byte{0},
[]byte{255},
[]byte{1, 255},
{0},
{255},
{1, 255},
}
for _, b := range cases {
next := nextKey(b)
Expand Down

0 comments on commit a4459f2

Please sign in to comment.