Sylvain Viart wrote:
> In the lib, we got a bloc with
>
> 484 rescue Exception => e
>
> Which I would expect to catch anything. but it missed
> Errno::EHOSTUNREACH.
Probably I should not try to answer this as I don't use Net::SSH::Multi,
but I've installed the gem now:
Successfully installed net-ssh-2.0.4
Successfully installed net-ssh-gateway-1.0.0
Successfully installed net-ssh-multi-1.0.0
I see that rescue only covers the preceding line:
begin
server.new_session
rescue Exception => e
That is, it will catch an exception raised by server.new_session only.
> Strangely, if I add another rescue statement in the lib:
>
> /var/lib/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/./multi/session.rb
> 506 rescue
> 507 puts "caught:#{$!}"
> 508 end
>
> it works?? Why?
Possibly it's rescuing an exception which is occurring between lines 469
and 480. But since you didn't show the actual backtrace, then this is
pure guesswork.
One option is:
puts "caught:#{$!}\n#{$!.backtrace.join("\n")}"
> Why the normally more open "rescue Exception => e" didn't do its job?
I don't know. But when making a extraordinary claim ("rescue is not
doing its job") then you need to provide the evidence to back it up.
Now, I can replicate something like your problem: pointing to a
non-existent host on my LAN gives an Errno::EHOSTUNREACH.
require 'rubygems'
require 'net/ssh/multi'
Net::SSH::Multi.start(

n_error => :warn) do |session|
# define the servers we want to use
session.use 'root@localhost'
session.use 'root@10.1.1.10' # non-existent host on local LAN
# execute commands on all servers
begin
session.exec( "hostname" )
rescue Exception => e
puts "main:#{e}\n#{e.backtrace.join("\n")}"
end
# run the aggregated event loop
session.loop
end
$ ruby test.rb
error connecting to root@localhost: Net::SSH::AuthenticationFailed
(root@localhost)
main:No route to host - connect(2)
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-2.0.4/lib/net/ssh/transport/session.rb:65:in
`initialize'
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session_actions.rb:37:in
`join'
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session_actions.rb:37:in
`sessions'
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session_actions.rb:37:in
`each'
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session_actions.rb:37:in
`sessions'
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session_actions.rb:81:in
`open_channel'
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session_actions.rb:120:in
`exec'
test.rb:10
/usr/local/lib/ruby/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi.rb:62:in
`start'
test.rb:3
I get an exception like you do. However I see no evidence at all that
lib/net/ssh/multi/session.rb is involved.
This is ruby 1.8.6p114. I don't have any specific reason why 1.8.5
wouldn't work, but I consider 1.8.6p114 to be the most "stable" Ruby
available (certainly more stable than later releases in the 1.8.6 family

and it may well be that Net::SSH::Multi hasn't been well tested with
1.8.5. So it could be worth a try.
--
Posted via
http://www.ruby-forum.com/.