interactive icon indicating copy to clipboard operation
interactive copied to clipboard

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

Open rasmuseeg opened this issue 2 years ago • 1 comments

Describe the bug

  • Created a new *.dib notebook
  • Add first new code cell with contents:
#!pwsh
$files = 1..10;
$processedFiles = @()
foreach($file in $files)
{
    Write-Host "Processing file: file${file}.txt"
    Start-Sleep -Seconds 1
    $processedFiles += "file${file}.txt"
}
  • Add second new code cell with contents:
#!pwsh
# Add command to pipeline queue
$processedFiles | ForEach-Object { Write-Host "Adding file to pipeline: $_"; Start-Sleep -Seconds 1; $_ } | Out-Null
  • Click the "Run All"
  • When the first cell completes
  • The second cell shows an error, but finishes:
Error: System.Management.Automation.PSInvalidOperationException: A pipeline is already running. Concurrent SessionStateProxy method calls are not allowed.
at System.Management.Automation.Runspaces.RunspaceBase.DoConcurrentCheckAndMarkSessionStateProxyCallInProgress()
at System.Management.Automation.Runspaces.RunspaceBase.get_InvokeProvider()
at System.Management.Automation.Runspaces.SessionStateProxy.get_InvokeProvider()
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
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
at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Kernel.cs:line 324
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
at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 51

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
  • OS
    • [x] Windows 11
    • [x] Windows 10
    • [ ] macOS
    • [ ] Linux (Please specify distro)
    • [ ] iOS
    • [ ] Android
  • Browser
    • [ ] Chrome
    • [ ] Edge
    • [ ] Firefox
    • [ ] Safari
  • Frontend
    • [x] Jupyter Notebook
    • [ ] Jupyter Lab
    • [ ] nteract
    • [x] Visual Studio Code
    • [ ] Visual Studio Code Insiders
    • [ ] Visual Studio
    • [x] Other (please specify)
    • [x] Polyglot Notebook Extension

Screenshots

Screenshot 2023-10-17 111554

rasmuseeg avatar Oct 17 '23 09:10 rasmuseeg

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.

nullptrerror avatar Oct 27 '23 15:10 nullptrerror