Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve notification loop exit #5233

Merged
merged 2 commits into from
Aug 9, 2024
Merged

Improve notification loop exit #5233

merged 2 commits into from
Aug 9, 2024

Conversation

sebastienros
Copy link
Member

@sebastienros sebastienros commented Aug 8, 2024

  • Cancel WaitAsync loop when text is found.
  • Ignore OperationCanceledException as they are expected.
Microsoft Reviewers: Open in CodeFlow

@sebastienros sebastienros requested a review from eerhardt August 8, 2024 23:42
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Aug 8, 2024
@@ -77,21 +74,23 @@ await foreach (var resourceEvent in resourceNotificationService.WatchAsync(cance
if (loggingResourceIds.Add(resourceId))
{
// Start watching the logs for this resource ID
logWatchTasks.Add(WatchResourceLogs(tcs, resourceId, logTexts, resourceLoggerService, cancellationToken));
logWatchTasks.Add(WatchResourceLogs(tcs, resourceId, logTexts, resourceLoggerService, cancellationTokenSource));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using logWatchTasks here to root them to the method so they don't get collected?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these would just be on the ThreadPool so they wouldn't be collected, but not sure. Feels safer this way, unless someone says it's fine without.


await Task.WhenAny(logWatchTasks).ConfigureAwait(false);
}
catch (OperationCanceledException)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this restricted to the case where cancellationTokenSource.IsCancellationRequested==true?

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sebastienros sebastienros enabled auto-merge (squash) August 9, 2024 22:19
@sebastienros sebastienros merged commit 7263e53 into main Aug 9, 2024
11 checks passed
@sebastienros sebastienros deleted the sebros/notificationloop branch August 9, 2024 23:19
@github-actions github-actions bot locked and limited conversation to collaborators Sep 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants