From: Akira ODA Date: 2007-03-04T10:48:35+09:00 Subject: [ruby-dev:30477] ThreadError on shell.rb はじめまして、尾田といいます。 shell.rb を使ったちょっとしたスクリプトを書いて大量のファイル(3000ファイル; 11GB)を 処理していたら途中で止まってしまいました。 スクリプト自体に問題はないと思うので、一応報告まで。 以下、スタックトレースと停止したスクリプトです。 require 'pathname' require 'shell' require 'optparse' def main(from, to, debug, commands) files = [] from.find do |path| files << path if path.file? end if debug > 0 STDERR.puts "from_dir = #{from.to_s}" STDERR.puts "to_dir = #{to.to_s}" end files.sort.each do |file| dest = to + file.relative_path_from(from) dest.parent.mkpath if debug > 0 STDERR.puts "input = #{file.to_s}" STDERR.puts "output = #{dest.to_s}" end Shell.new.transact do cat(file.to_s) | system(*commands) > dest.to_s end end end if $0 == __FILE__ from = nil to = nil debug = 0 opt = OptionParser.new opt.on('-t', '--to TO', String) {|v| to = Pathname.new v} opt.on('-f', '--from FROM', String) {|v| from = Pathname.new v} opt.on('-d', '--debug') { debug += 1 } opt.parse!(ARGV) unless from and to and ARGV.length > 0 puts opt.help exit end main(from, to, debug, ARGV) end /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:203:in `stop': stopping only thread (ThreadError) note: use sleep to stop forever from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:203:in `wait' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:155:in `exclusive_unlock' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:33:in `exclusive' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:147:in `exclusive_unlock' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:201:in `wait' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/process-controller.rb:185:in `wait_all_jobs_execution' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:135:in `synchronize' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/process-controller.rb:182:in `wait_all_jobs_execution' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/command-processor.rb:246:in `check_point' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/command-processor.rb:254:in `transact' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/command-processor.rb:519:in `__send__' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/command-processor.rb:519:in `transact' from ./bin/dir_filter.rb:27:in `main' from ./bin/dir_filter.rb:18:in `each' from ./bin/dir_filter.rb:18:in `main' -- Akira ODA