Skip to content

Commit

Permalink
Prevent UnobservedTaskException in LeaderElector
Browse files Browse the repository at this point in the history
  • Loading branch information
klesta490 authored and Vladimír Kleštinec committed Oct 2, 2023
1 parent 2899a13 commit 20d0a81
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/KubernetesClient/LeaderElection/LeaderElector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,11 @@ private async Task AcquireAsync(CancellationToken cancellationToken)
// wait RetryPeriod since acq return immediately
await Task.Delay(delay, cancellationToken).ConfigureAwait(false);
}

// else timeout
else
{
// else timeout
_ = acq.ContinueWith(t => _ = t.Exception /* prevent UnobservedTaskException */, TaskContinuationOptions.OnlyOnFaulted);
}
}
finally
{
Expand Down

0 comments on commit 20d0a81

Please sign in to comment.