# Exception in thread?

**URL:** <https://rubytalk.org/t/exception-in-thread/49357>\
**Category:** ruby-talk\
**Created:** [29 September 2008 16:22 UTC](https://rubytalk.org/t/exception-in-thread/49357 "2008-09-29T16:22:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sylvain\_Viart1](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Sylvain\_Viart1](https://rubytalk.org/u/Sylvain_Viart1)\
**Post date:** [29 September 2008 16:22 UTC](https://rubytalk.org/t/exception-in-thread/49357/1 "2008-09-29T16:22:52Z")

</div>

Hi,

I'm trying to use Net::SSH::Multi. [http://net-ssh.rubyforge.org/](http://net-ssh.rubyforge.org/)

It seems that ruby have difficulties to catch exception in multi threaded mode, any hint?

the doc said, if we put (:on\_error =\> :warn) it shouldn't fail, be the exception begin/rescue bloc did catch the exception, here Errno::EHOSTUNREACH

/var/lib/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/./multi/session.rb  
468 def next\_session(server, force=false) #:nodoc:  
[...]  
482 begin  
483 server.new\_session  
484 rescue Exception =\> e  
485 server.fail!  
486 @session\_mutex.synchronize { @open\_connections -= 1 }  
487  
488 case on\_error  
489 when :ignore then  
490 # do nothing  
491 when :warn then  
492 warn("error connecting to #{server}: #{e.class} (#{e.message})")  
493 when Proc then  
494 go = catch(:go) { on\_error.call(server); nil }  
495 case go  
496 when nil, :ignore then # nothing  
497 when :retry then retry  
498 when :raise then raise  
499 else warn "unknown 'go' command: #{go.inspect}"  
500 end  
501 else  
502 raise  
503 end  
504  
505 return nil  
506 end  
[...]

As we can test, we are able to catch the exception at to level, could you confirm its tread related?

require 'rubygems'  
require 'net/ssh/multi'  
Net::SSH::Multi.start(:on\_error =\> :warn) do |session|  
&nbsp;&nbsp;# define the servers we want to use  
&nbsp;&nbsp;session.use 'root@server-04'  
&nbsp;&nbsp;session.use 'root@server-07' # doesn't exist  
&nbsp;&nbsp;session.use 'root@server-08'

&nbsp;&nbsp;# execute commands on all servers  
begin  
&nbsp;&nbsp;&nbsp;&nbsp;session.exec( "hostname" )  
rescue Exception =\> e  
&nbsp;&nbsp;&nbsp;&nbsp;p "main:#{e}"  
end

&nbsp;&nbsp;# run the aggregated event loop  
&nbsp;&nbsp;session.loop  
end

ruby 1.8.5 (2006-08-25) [x86\_64-linux]

Regards,  
Sylvain.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [30 September 2008 08:53 UTC](https://rubytalk.org/t/exception-in-thread/49357/2 "2008-09-30T08:53:22Z")

</div>

Sylvain Viart wrote:

> It seems that ruby have difficulties to catch exception in multi  
> threaded mode, any hint?

For debugging purposes, maybe you want Thread.abort\_on\_exception = true  
(or just run ruby with -d flag)

Other than that I don't understand your problem. What behaviour do you  
see when you run your test program? What behaviour do you expect? Is no  
warning generated for the non-existent host?

> &nbsp;&nbsp;# execute commands on all servers  
> begin  
> &nbsp;&nbsp;&nbsp;&nbsp;session.exec( "hostname" )  
> rescue Exception =\> e  
> &nbsp;&nbsp;&nbsp;&nbsp;p "main:#{e}"  
> end

That rescue won't catch exceptions in other threads. Each thread of  
execution is responsible for catching its own exceptions. If it doesn't,  
then the thread just terminates (unless Thread.abort\_on\_exception is  
set)

It \*is\* possible for one thread to raise an exception in another thread  
(Thread#raise), but this is extremely hairy asynchronous programming and  
I would strongly discourage it.

It would seem reasonable for session.exec to collect the status of each  
of the threads and return an array of them. I don't know if it does so.  
Perhaps you can use something like this:

&nbsp;&nbsp;&nbsp;&nbsp;errs =   
&nbsp;&nbsp;&nbsp;&nbsp;...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:on\_error =\> lambda { |server| errs \<\< server }  
&nbsp;&nbsp;&nbsp;&nbsp;...  
&nbsp;&nbsp;&nbsp;&nbsp;session.exec "hostname"  
&nbsp;&nbsp;&nbsp;&nbsp;unless errs.empty?  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "The command failed on #{errs.size} hosts"  
&nbsp;&nbsp;&nbsp;&nbsp;end

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Sylvain\_Viart1](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Sylvain\_Viart1](https://rubytalk.org/u/Sylvain_Viart1)\
**Post date:** [30 September 2008 11:13 UTC](https://rubytalk.org/t/exception-in-thread/49357/3 "2008-09-30T11:13:55Z")

</div>

Hi Brian,

Brian Candler a écrit :

> Sylvain Viart wrote:  
> &nbsp;&nbsp;
> 
> > It seems that ruby have difficulties to catch exception in multi  
> > threaded mode, any hint?  
> > &nbsp;&nbsp;&nbsp;&nbsp;  
> > For debugging purposes, maybe you want Thread.abort\_on\_exception = true (or just run ruby with -d flag)  
> > &nbsp;&nbsp;

Thanks good to know that.

> Other than that I don't understand your problem. What behaviour do you see when you run your test program? What behaviour do you expect?

Sorry, I was late yesterday and my post is confusing.

In fact, I've made some tests and I suspect some strange behavior (or unknown to me) on exception handling.  
In the lib, we got a bloc with

484 rescue Exception =\> e

Which I would expect to catch anything. but it missed Errno::EHOSTUNREACH.  
I didn't find a good explanation so I suspect that exception in threads are behaving somewhat differently.

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?

Why the normally more open "rescue Exception =\> e" didn't do its job?  
That's why I suspect some interaction between exception and threaded execution.  
It seems I missed something about exception or so. :-\

> Is no warning generated for the non-existent host?
> 
> > &nbsp;&nbsp;# execute commands on all servers  
> > begin  
> > &nbsp;&nbsp;&nbsp;&nbsp;session.exec( "hostname" )  
> > rescue Exception =\> e  
> > &nbsp;&nbsp;&nbsp;&nbsp;p "main:#{e}"  
> > end  
> > &nbsp;&nbsp;&nbsp;&nbsp;

Sorry for that, I was expecting this bloc not using the begin/rescue in fact.  
The rescue here, catch the Errno::EHOSTUNREACH., not caught internally by the lib.

I should have written:

session.exec( "hostname" )

With no rescue, the program fail, no job is performed on any host.

> It would seem reasonable for session.exec to collect the status of each of the threads and return an array of them. I don't know if it does so. Perhaps you can use something like this:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;errs =   
> &nbsp;&nbsp;&nbsp;&nbsp;...  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:on\_error =\> lambda { |server| errs \<\< server }  
> &nbsp;&nbsp;&nbsp;&nbsp;...  
> &nbsp;&nbsp;&nbsp;&nbsp;session.exec "hostname"  
> &nbsp;&nbsp;&nbsp;&nbsp;unless errs.empty?  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "The command failed on #{errs.size} hosts"  
> &nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;

Hum, nice, I'm gonna try. 🙂  
Would it catch the Errno::EHOSTUNREACH?

Thanks for your hints.  
Regards,  
Sylvain.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [30 September 2008 14:13 UTC](https://rubytalk.org/t/exception-in-thread/49357/4 "2008-09-30T14:13:54Z")

</div>

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:

&nbsp;&nbsp;&nbsp;&nbsp;Successfully installed net-ssh-2.0.4  
&nbsp;&nbsp;&nbsp;&nbsp;Successfully installed net-ssh-gateway-1.0.0  
&nbsp;&nbsp;&nbsp;&nbsp;Successfully installed net-ssh-multi-1.0.0

I see that rescue only covers the preceding line:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server.new\_session  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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:

&nbsp;&nbsp;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(:on\_error =\> :warn) do |session|  
&nbsp;&nbsp;# define the servers we want to use  
&nbsp;&nbsp;session.use 'root@localhost'  
&nbsp;&nbsp;session.use 'root@10.1.1.10' # non-existent host on local LAN

&nbsp;&nbsp;# execute commands on all servers  
begin  
&nbsp;&nbsp;&nbsp;&nbsp;session.exec( "hostname" )  
rescue Exception =\> e  
&nbsp;&nbsp;&nbsp;&nbsp;puts "main:#{e}\n#{e.backtrace.join("\n")}"  
end

&nbsp;&nbsp;# run the aggregated event loop  
&nbsp;&nbsp;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/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Sylvain\_Viart1](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Sylvain\_Viart1](https://rubytalk.org/u/Sylvain_Viart1)\
**Post date:** [30 September 2008 15:36 UTC](https://rubytalk.org/t/exception-in-thread/49357/5 "2008-09-30T15:36:11Z")

</div>

Hi,

Sylvain Viart a écrit :

> > It would seem reasonable for session.exec to collect the status of each of the threads and return an array of them. I don't know if it does so. Perhaps you can use something like this:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;errs =   
> > &nbsp;&nbsp;&nbsp;&nbsp;...  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:on\_error =\> lambda { |server| errs \<\< server }  
> > &nbsp;&nbsp;&nbsp;&nbsp;...  
> > &nbsp;&nbsp;&nbsp;&nbsp;session.exec "hostname"  
> > &nbsp;&nbsp;&nbsp;&nbsp;unless errs.empty?  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "The command failed on #{errs.size} hosts"  
> > &nbsp;&nbsp;&nbsp;&nbsp;end
> 
> Hum, nice, I'm gonna try. 🙂  
> Would it catch the Errno::EHOSTUNREACH?

It didn't catch the exception

a workaround, using a closure and Net::SSH::Multi::DynamicServer \<[http://net-ssh.rubyforge.org/multi/v1/api/classes/Net/SSH/Multi/DynamicServer.html&gt](http://net-ssh.rubyforge.org/multi/v1/api/classes/Net/SSH/Multi/DynamicServer.html&gt); behavior, instead of specifying the server. It's evaluated by attempting the ssh connection first. Which mean the server, is connected twice, during the test and later in the session. Note that I discard the 'options' to test the connection.

errs =   
def test\_server(errs, server)  
&nbsp;&nbsp;&nbsp;&nbsp;lambda do |options|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server =~ /(.+)@(.+)/  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server\_name, user = $2, $1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts server\_name  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s = Net::SSH.start(server\_name, user)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s.close  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s = server  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rescue Errno::EHOSTUNREACH, SocketError  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "echec connexion #{server} : #{$!}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errs \<\< server  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s = nil  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return s  
&nbsp;&nbsp;&nbsp;&nbsp;end  
end

Net::SSH::Multi.start(:on\_error =\> :warn) do |session|  
&nbsp;&nbsp;# define the servers we want to use  
&nbsp;&nbsp;session.use &test\_server(errs, 'root@srv-04')  
&nbsp;&nbsp;session.use &test\_server(errs, 'root@srv-07')  
&nbsp;&nbsp;session.use &test\_server(errs, 'root@srv-08')  
&nbsp;&nbsp;session.use &test\_server(errs, 'root@fail-08.local')

&nbsp;&nbsp;# execute commands on all servers  
&nbsp;&nbsp;session.exec( "hostname" )

&nbsp;&nbsp;# run the aggregated event loop  
&nbsp;&nbsp;session.loop  
end

unless errs.empty?  
&nbsp;&nbsp;puts "The command failed on #{errs.size} hosts"  
end

#srv-04  
#srv-07  
#echec connexion root@srv-07 : No route to host - connect(2)  
#srv-08  
#fail-08.local  
#echec connexion root@fail-08.local : getaddrinfo: Name or service not known  
#[srv-04] srv-04  
#[srv-08] srv-08  
#The command failed on 2 hosts

Works, but I still don't know why the exception are not handled in the lib Net::SSH::Multi which may be specific to this lib.  
I still appreciate some more hint.

Regards,  
Sylvain.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [30 September 2008 20:49 UTC](https://rubytalk.org/t/exception-in-thread/49357/6 "2008-09-30T20:49:07Z")

</div>

Sylvain Viart wrote:

> Works, but I still don't know why the exception are not handled in the  
> lib Net::SSH::Multi which may be specific to this lib.

Show the backtrace! Otherwise, nobody is going to be able to help you.

That is, in your original demo code, either remove the top-level rescue  
clause entirely, or change it to

rescue Exception =\> e  
&nbsp;&nbsp;&nbsp;&nbsp;puts "main:#{e}\n#{e.backtrace.join("\n")}"  
end

Then paste the full, unedited result here.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Sylvain\_Viart1](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@Sylvain\_Viart1](https://rubytalk.org/u/Sylvain_Viart1)\
**Post date:** [3 October 2008 07:39 UTC](https://rubytalk.org/t/exception-in-thread/49357/7 "2008-10-03T07:39:55Z")

</div>

Hi Brian,

Thanks a lot for your work, I really appreciate your effort. 🙂

Brian Candler a écrit :

> Sylvain Viart wrote:  
> &nbsp;&nbsp;
> 
> > Works, but I still don't know why the exception are not handled in the  
> > lib Net::SSH::Multi which may be specific to this lib.  
> > &nbsp;&nbsp;&nbsp;&nbsp;  
> > Show the backtrace! Otherwise, nobody is going to be able to help you.  
> > &nbsp;&nbsp;

Sorry for that, I'm not enough backtrace friendly. :-\

----------------------------8\<----------------------- t3.rb  
require 'rubygems'  
require 'net/ssh/multi'

Net::SSH::Multi.start(:on\_error =\> :warn) do |session|  
&nbsp;&nbsp;# define the servers we want to use  
&nbsp;&nbsp;session.use 'root@srv-04'  
&nbsp;&nbsp;session.use 'root@srv-07'  
&nbsp;&nbsp;session.use 'root@srv-08'  
&nbsp;&nbsp;session.use 'root@fail-08.local'

&nbsp;&nbsp;# execute commands on all servers  
&nbsp;&nbsp;session.exec( "hostname" )

&nbsp;&nbsp;# run the aggregated event loop  
&nbsp;&nbsp;session.loop  
end  
----------------------------8\<-----------------------

ruby t3.rb  
error connecting to root@srv-04: Net::SSH::AuthenticationFailed (root@srv-04)  
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.  
Password: /var/lib/gems/1.8/gems/net-ssh-2.0.4/lib/net/ssh/transport/session.rb:65:in `initialize': No route to host - connect(2) (Errno::EHOSTUNREACH)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /var/lib/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session\_actions.rb:37:in `join'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /var/lib/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session\_actions.rb:37:in `sessions'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /var/lib/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session\_actions.rb:37:in `each'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /var/lib/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session\_actions.rb:37:in `sessions'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /var/lib/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session\_actions.rb:81:in `open\_channel'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /var/lib/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi/session\_actions.rb:120:in `exec'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from t3.rb:12  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /var/lib/gems/1.8/gems/net-ssh-multi-1.0.0/lib/net/ssh/multi.rb:62:in `start'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from t3.rb:4

shell returned 1

I think you're right and this kind of exception is not handled by the lib.  
I've to reread the lib, but its doc is confusing.

Regards,  
Sylvain.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [3 October 2008 07:57 UTC](https://rubytalk.org/t/exception-in-thread/49357/8 "2008-10-03T07:57:31Z")

</div>

It does seem inconsistent that "error connecting to root@srv-04:  
Net::SSH::AuthenticationFailed" is caught as a warning, but  
Errno::EHOSTUNREACH is not. I suggest you check for a project mailing  
list or bug tracker and report it there.  
[http://rubyforge.org/projects/net-ssh](http://rubyforge.org/projects/net-ssh)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
