From f0ca06ba0683d36f99afd6c5d274738b0c030cc8 Mon Sep 17 00:00:00 2001 From: James Suplizio Date: Mon, 13 Mar 2023 10:15:04 -0700 Subject: [PATCH] Update the retry loop to try 5x and use Task.Delay instead of Thread.Sleep --- .../GitHubEventClient.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/GitHubEventClient.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/GitHubEventClient.cs index 2cc7600185b..b0c27ec0d94 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/GitHubEventClient.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/GitHubEventClient.cs @@ -651,9 +651,9 @@ public SearchIssuesRequest CreateSearchRequest(string repoOwner, /// OctoKit.SearchIssuesResult public virtual async Task 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 @@ -688,8 +688,10 @@ public virtual async Task 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); } } }