Skip to content

Commit

Permalink
Update the retry loop to try 5x and use Task.Delay instead of Thread.…
Browse files Browse the repository at this point in the history
…Sleep
  • Loading branch information
JimSuplizio committed Mar 13, 2023
1 parent e5574ef commit f0ca06b
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,9 @@ public SearchIssuesRequest CreateSearchRequest(string repoOwner,
/// <returns>OctoKit.SearchIssuesResult</returns>
public virtual async Task<SearchIssuesResult> QueryIssues(SearchIssuesRequest searchIssuesRequest)
{
int maxTries = 3;
// 90 seconds
int sleepDuration = 90000;
int maxTries = 5;
// 61 seconds
int sleepDuration = 61000;
for (int tryNumber = 1; tryNumber <= maxTries; tryNumber++)
{
try
Expand Down Expand Up @@ -688,8 +688,10 @@ public virtual async Task<SearchIssuesResult> QueryIssues(SearchIssuesRequest se
}
else
{
Console.WriteLine($"QueryIssues, sleeping for {sleepDuration/1000} seconds before retrying.");
System.Threading.Thread.Sleep(sleepDuration);
Console.WriteLine($"QueryIssues, sleeping for {sleepDuration/61} seconds before retrying.");
// Task.Delay over Sleep will push the wait into the IO completion state and unblocks the thread
// from the threadpool whereas sleep blocks the thread in the threadpool.
await Task.Delay(tryNumber * sleepDuration);
}
}
}
Expand Down

0 comments on commit f0ca06b

Please sign in to comment.