Issue with multi threading

1 require 'net/ssh'
2 Net::SSH.start('10.10.2.3', 'test', :password => "test123") do |ssh|
3 productsList=['test1', 'test2', 'test3', 'test4', 'test5']
4 puts Time.now
5 threads =
6 for product in productsList
7 threads << Thread.new(product) { |product1|
8 baseDir='$HOME/Repository/'
9 fileslist=
10 confFolders=['conf', 'bin']
11 confFolders.each{|confFolder|
12
13 stdout = ""
14 fileslist_temp=
15
16 puts "path: ls -1 #{baseDir}/#{product1}/#{confFolder}/"
17 ssh.exec!("ls -1 #{baseDir}/#{product1}/#{confFolder}/") do

channel, stream, data|

18 stdout<< data if stream == :stdout
19 end
20 fileslist_temp=stdout.split("\n")
21 fileslist_temp.each{|file|
22 file.strip!
23 temp="#{confFolder}/"+file
24 fileslist.push(temp)
25 }
26 }
27 config_files_list=fileslist.join(", ")
28 puts "#{product1} Proudct List: #{config_files_list}"
39 }
30 end
31 threads.each { |aThread| aThread.join }
32 puts Time.now
33 end

Above program is giving below exception, please help me to fix this
issue.

C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:200:in
`select': An operation was attempted on something that is not a socket.
(Errno::ENOTSOCK)
  from
C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:200:in
`process'
  from
C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:160:in
`block in loop'
  from
C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:160:in
`loop'
  from
C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:160:in
`loop'
  from
C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/channel.rb:269:in
`wait'
  from
C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:354:in
`exec!'
  from Thread.rb:17:in `block (4 levels) in <main>'
  from Thread.rb:12:in `each'
  from Thread.rb:12:in `block (3 levels) in <main>'
2009-06-19 11:28:43 +0530
path: ls -1 $HOME/Repository//test1/conf/
path: ls -1 $HOME/Repository//test2/conf/
path: ls -1 $HOME/Repository//test3/conf/
path: ls -1 $HOME/Repository//test4/conf/
path: ls -1 $HOME/Repository//test5/conf/

Attachments:
http://www.ruby-forum.com/attachment/3832/Thread.rb

···

--
Posted via http://www.ruby-forum.com/\.

C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:200:in
`select': An operation was attempted on something that is not a socket.
(Errno::ENOTSOCK)
  from

It might be related to
http://redmine.ruby-lang.org/issues/show/1541
does it occur rarely? what version of ruby?
-=r

···

--
Posted via http://www.ruby-forum.com/\.

Roger Pack wrote:

C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:200:in
`select': An operation was attempted on something that is not a socket.
(Errno::ENOTSOCK)
  from

It might be related to
http://redmine.ruby-lang.org/issues/show/1541
does it occur rarely? what version of ruby?
-=r

Hi Roger Pack,

Ruby version
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32]

Frequency occurring of this issue is 8 times out of 10.

···

--
Posted via http://www.ruby-forum.com/\.

Google as always is your friend (net:ssh multithread)

http://weblog.jamisbuck.org/2008/3/18/net-ssh-and-thread-safety - hit #1

John

···

On Sun, Jun 21, 2009 at 9:53 PM, Rajeswar reddy Gaulla < rajeswarr@ivycomptech.com> wrote:

Roger Pack wrote:
>>
C:/Ruby/lib/ruby/gems/1.9.1/gems/net-ssh-2.0.11/lib/net/ssh/connection/session.rb:200:in
>> `select': An operation was attempted on something that is not a socket.
>> (Errno::ENOTSOCK)
>> from
>
> It might be related to
> http://redmine.ruby-lang.org/issues/show/1541
> does it occur rarely? what version of ruby?
> -=r