dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.8k stars 374 forks source link

PSInvalidOperationException: A pipeline is already running. Concurrent SessionStateProxy method calls are not allowed. #3266

Open rasmuseeg opened 8 months ago

rasmuseeg commented 8 months ago

Describe the bug

Please complete the following:

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

.NET Interactive
© 2020 Microsoft Corporation
Version: 1.0.451402+c98f093c24bc8c2479e381d51e6c481ea48206a9
Library version: 1.0.0-beta.23514.2+c98f093c24bc8c2479e381d51e6c481ea48206a9
Build date: 2023-10-17T07:22:14.2772234Z
https://github.com/dotnet/interactive

Screenshots

Screenshot 2023-10-17 111554

nullptrerror commented 8 months ago

I have the same issue. I'm using the Polyglot Notebooks v1.0.4517010

My first job deletes the local git folder if it exists I tried making it a thread job to await for it but no luck.

first job:

Start-ThreadJob -ScriptBlock {
    function Delete-GitFolder {
        $messages = @()
        try {
            $gitPath = Join-Path $PWD -ChildPath '.git'
            $messages += Remove-Item -Path $gitPath -Recurse -Force -ErrorAction Stop -Verbose *>&1
        } catch {
            $messages += "Safe Exception: $($_.Exception.Message)"
        }
        $messages
    }
    Delete-GitFolder
} | Wait-Job | Receive-Job | ForEach-Object { Write-Host "# 0. $_" } | Remove-Job

second job:

Start-ThreadJob -ScriptBlock {
    function Run-GitInit {
        $messages = @()
        try {
            $message = git init .
            if(-not $message -or -not $message.GetType().Name -eq 'String') { $message = "git init ." }
            $messages += $message
        } catch {
            $messages += "Exception: $($_.Exception.Message)"
        }
        $messages
    }
    Run-GitInit
} | Wait-Job | Receive-Job | ForEach-Object { Write-Host "# 5. $_" } | Remove-Job

image

.NET Interactive Version: 1.0.451701+e231cd6f4a395b6f74568c5ad95a15cbecb85cf2 Library version: 1.0.0-beta.23517.1+e231cd6f4a395b6f74568c5ad95a15cbecb85cf2 Build date: 2023-10-26T17:07:37.4023382Z

{
    "name": "Error",
    "message": "System.Management.Automation.PSInvalidOperationException: A pipeline is already running. Concurrent SessionStateProxy method calls are not allowed.\r
   at System.Management.Automation.Runspaces.RunspaceBase.DoConcurrentCheckAndMarkSessionStateProxyCallInProgress()\r
   at System.Management.Automation.Runspaces.RunspaceBase.get_InvokeProvider()\r
   at System.Management.Automation.Runspaces.SessionStateProxy.get_InvokeProvider()\r
   at Microsoft.DotNet.Interactive.PowerShell.PowerShellKernel.Microsoft.DotNet.Interactive.IKernelCommandHandler<Microsoft.DotNet.Interactive.Commands.RequestValueInfos>.HandleAsync(RequestValueInfos command, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive.PowerShell\\PowerShellKernel.cs:line 175\r
   at Microsoft.DotNet.Interactive.Kernel.<>c__DisplayClass82_0`1.<SetHandler>b__0(KernelCommand _, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\Kernel.cs:line 867\r
   at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\Kernel.cs:line 324\r
   at Microsoft.DotNet.Interactive.KernelCommandPipeline.<BuildPipeline>b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\KernelCommandPipeline.cs:line 60\r
   at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\KernelCommandPipeline.cs:line 51"
}

Futher more I get an occasional:

{
    "name": "Error",
    "message": "Microsoft.DotNet.Interactive.NoSuitableKernelException: No kernel found for Microsoft.DotNet.Interactive.Commands.RequestHoverText with target kernel 'pwsh'.\r
   at Microsoft.DotNet.Interactive.Commands.KernelCommand.InvokeAsync(KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\Commands\\KernelCommand.cs:line 184\r
   at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\Kernel.cs:line 324\r
   at Microsoft.DotNet.Interactive.KernelCommandPipeline.<BuildPipeline>b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\KernelCommandPipeline.cs:line 60\r
   at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\\a\\_work\\1\\s\\src\\Microsoft.DotNet.Interactive\\KernelCommandPipeline.cs:line 51"
}

By the way to the guys who maintain this you guys are amazing. THe ability and concept of programing and documenting is amazing.