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

Console output can be lost when cell execution is canceled #3772

Open
jonsequitur opened this issue Nov 20, 2024 · 0 comments
Open

Console output can be lost when cell execution is canceled #3772

jonsequitur opened this issue Nov 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jonsequitur
Copy link
Contributor

jonsequitur commented Nov 20, 2024

The console output "Dispose" does not appear when the following code is canceled.

using System.Threading.Tasks;
using Microsoft.DotNet.Interactive;

Console.WriteLine("initialize");

var output = string.Empty.Display("text/plain");
var counter = 1;
while (!KernelInvocationContext.Current.CancellationToken.IsCancellationRequested)
{
    await Task.Delay(500);
    output.Update($"{counter++}");
}

Console.WriteLine("Dispose");

var completed = true;
``` 

This is because the `KernelInvocationContext` stops listening to console output and publishing events when it's completed. The behavior is unintuitive though and could perhaps be changed so that event publishing continues for long enough to capture this output.

More details here:
https://github.com/dotnet/interactive/issues/2987#issuecomment-2489136012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant