interactive icon indicating copy to clipboard operation
interactive copied to clipboard

Stop Execution button does not stop the infinite for loop

Open princeanire opened this issue 2 years ago • 3 comments

Describe the bug

The Stop Execution button on polyglot notebook doesn't stop the execution of an infinite for loop such as:

for ( ; ; )
{
    //...
}

My current workaround to stop an infinite for loop is to restart the kernel, although sometimes, the Stop Execution does stop an infinite for loop or execution of a cell

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

  • OS
    • [x] Windows 11
    • [ ] Windows 10
    • [ ] macOS
    • [ ] Linux (Please specify distro)
    • [ ] iOS
    • [ ] Android
  • Browser
    • [ ] Chrome
    • [x] Edge
    • [ ] Firefox
    • [ ] Safari
  • Frontend
    • [ ] Jupyter Notebook
    • [ ] Jupyter Lab
    • [ ] nteract
    • [x] Visual Studio Code
    • [ ] Visual Studio Code Insiders
    • [ ] Visual Studio
    • [ ] Other (please specify)

Screenshots

image image image

princeanire avatar Dec 18 '23 14:12 princeanire

The cancel button will not cancel infinite loops, since .NET Core / .NET 5 / .NET 6 did not support an equivalent of .NET Framework's Thread.Abort. We are working on a potential fix using the ControlledExecution API introduced in .NET 7.

Related: #3049.

jonsequitur avatar Dec 18 '23 17:12 jonsequitur

Thanks for the clarification! It would be helpful if I can cancel infinite loops as sometimes, I create infinite loops by mistake and for now, I can only stop those infinite loops by restarting the kernel, affect other cells as well.

Looking forward to the fix and appreciate the prompt response!

princeanire avatar Dec 22 '23 08:12 princeanire