Sha256: 3730d286ee787b238286e5b7a996a91705b5a4ac870bde0adc0548ed2de70994
Contents?: true
Size: 1 KB
Versions: 23
Compression:
Stored size: 1 KB
Contents
# usage: # ruby -I lib -r session test/threadtest.rb # SESSION_USE_SPAWN=1 ruby -I lib -r session test/threadtest.rb %w(lib ../lib . ..).each{|d| $:.unshift d} require 'session' def display obj Thread.critical = true STDOUT.print obj STDOUT.flush ensure Thread.critical = false end $VERBOSE=nil STDOUT.sync = true STDERR.sync = true STDOUT.puts "Session::VERSION <#{ Session::VERSION }>" STDOUT.puts "Session.use_spawn <#{ Session.use_spawn ? 'true' : 'false' }>" STDOUT.puts "the timestamps of each tid should come back about 1 second apart or there are problems..." STDOUT.puts threads = [] 3.times do |i| threads << Thread::new(i) do |i| cmd = 'echo 42; sleep 1;' * 3 sh = Session.new #:use_spawn=>true sh.execute(cmd) do |o,e| which = o ? 'stdout' : 'stderr' line = (o || e).strip indent = '| ' * i display "#{ indent }tid<#{ i }> #{ which }<#{ line }> time<#{ Time.now.to_f }>\n" end end sleep rand end threads.map{|t| t.join}
Version data entries
23 entries across 23 versions & 2 rubygems
Version | Path |
---|---|
redcar-0.3.8.1 | plugins/runnables/vendor/session-2.4.0/sample/threadtest.rb |
redcar-0.3.8 | plugins/runnables/vendor/session-2.4.0/sample/threadtest.rb |
session-3.1.0 | sample/threadtest.rb |