Skip to content

Commit 1499310

Browse files
author
Vladimír Kleštinec
committed
Prevent UnobservedTaskException in LeaderElector
1 parent 2899a13 commit 1499310

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/KubernetesClient/LeaderElection/LeaderElector.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,11 @@ private async Task AcquireAsync(CancellationToken cancellationToken)
211211
// wait RetryPeriod since acq return immediately
212212
await Task.Delay(delay, cancellationToken).ConfigureAwait(false);
213213
}
214-
215-
// else timeout
214+
else
215+
{
216+
// else timeout
217+
_ = acq.ContinueWith(t => _ = t.Exception /* prevent UnobservedTaskException */, TaskContinuationOptions.OnlyOnFaulted);
218+
}
216219
}
217220
finally
218221
{

0 commit comments

Comments
 (0)