Skip to content

Commit

Permalink
Wondering if this captures the intent of what we'd like this function…
Browse files Browse the repository at this point in the history
… to be.
  • Loading branch information
annawinkler committed Jun 1, 2022
1 parent 382bf33 commit 4a5ffa3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1235,23 +1235,22 @@ func waitForRunLock(t *testing.T, client *Client, workspaceID string) {

func retry(f retryableFn) (interface{}, error) { //nolint
tick := time.NewTicker(tickDuration * time.Second)

retries := 0
maxRetries := 5

for {
if tick.C != nil {
res, err := f()
if err == nil {
return res, nil
}
defer tick.Stop()

if retries >= maxRetries {
return nil, err
}
for {
res, err := f()
if err == nil {
return res, nil
}

retries += 1
if retries >= maxRetries {
return nil, err
}

retries += 1
}
}

Expand Down

0 comments on commit 4a5ffa3

Please sign in to comment.