diff --git a/lib/winrm/shells/power_shell.rb b/lib/winrm/shells/power_shell.rb index d9ca50d2..a291fc1d 100644 --- a/lib/winrm/shells/power_shell.rb +++ b/lib/winrm/shells/power_shell.rb @@ -34,12 +34,16 @@ def finalize(connection_opts, transport, shell_id) end def close_shell(connection_opts, transport, shell_id) + return false unless Thread.current.alive? + Thread.current.wakeup if Thread.current.status =~ /sleep/ msg = WinRM::WSMV::CloseShell.new( connection_opts, shell_id: shell_id, shell_uri: WinRM::WSMV::Header::RESOURCE_URI_POWERSHELL ) transport.send_request(msg.build) + rescue ThreadError => e + logger.debug("#{e.message}") end end