Skip to content

Instantly share code, notes, and snippets.

@maasha

maasha/open3.rb Secret

Created April 30, 2015 10:17
Show Gist options
  • Save maasha/da77da2bfa106a476af6 to your computer and use it in GitHub Desktop.
Save maasha/da77da2bfa106a476af6 to your computer and use it in GitHub Desktop.
Hangs after printing here1
Open3.popen3(cmd.join(" ")) do |stdin, stdout, stderr, wait_thr|
input.each_with_index do |record, i|
if record[:SEQ]
entry = BioPieces::Seq.new_bp(record)
entry.seq_name ||= i
stdin.puts entry.to_fasta
end
if output
output << record
status[:records_out] += 1
end
end
puts "here0"
stdin.close
puts "here1"
tree_data = stdout.read.chomp
puts "here2"
stdout.close
puts "here3"
exit_status = wait_thr.value
puts "here4"
raise stderr.read unless exit_status.success?
if options[:output]
File.open(options[:output], 'w') do |ios|
ios.puts tree_data
end
else
puts tree_data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment