Skip to content

Commit dd989f2

Browse files
committed
Don't immediatly poll for request cancellation
1 parent c6d3fa5 commit dd989f2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

source/Halibut/Queue/Redis/Cancellation/WatchForRequestCancellation.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ async Task WatchForCancellation(Uri endpoint, Guid requestActivityId, IHalibutRe
4848
// Also poll to see if the request is cancelled since we can miss the publication.
4949
while (!token.IsCancellationRequested)
5050
{
51+
await Try.IgnoringError(async () => await Task.Delay(TimeSpan.FromSeconds(60), token));
52+
53+
if(token.IsCancellationRequested) return;
54+
5155
try
5256
{
5357
if (await halibutRedisTransport.IsRequestMarkedAsCancelled(endpoint, requestActivityId, token))
@@ -61,7 +65,6 @@ async Task WatchForCancellation(Uri endpoint, Guid requestActivityId, IHalibutRe
6165
{
6266
log.Write(EventType.Diagnostic, "Error while polling for request cancellation - Endpoint: {0}, ActivityId: {1}, Error: {2}", endpoint, requestActivityId, ex.Message);
6367
}
64-
await Try.IgnoringError(async () => await Task.Delay(TimeSpan.FromSeconds(60), token));
6568
}
6669

6770
log.Write(EventType.Diagnostic, "Exiting watch loop for request cancellation - Endpoint: {0}, ActivityId: {1}", endpoint, requestActivityId);

0 commit comments

Comments
 (0)