jobQueue 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011, Ralf Mueller (stark.dreamdetective@googlemail.com)
1
+ Copyright (c) 2011-2012, Ralf Mueller (stark.dreamdetective@googlemail.com)
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@ require 'jobqueue'
9
9
  # ==============================================================================
10
10
 
11
11
  nTh = SystemJobs.maxnumber_of_processors
12
- options = {:workers => nTh,:debug => false}
12
+ options = {:workers => nTh,:debug => true}
13
13
  optparse = OptionParser.new do|opts|
14
14
  opts.banner = "Usage: prun.rb [options] command-files"
15
15
 
@@ -17,8 +17,12 @@ optparse = OptionParser.new do|opts|
17
17
  opts.on('-j [NUM]',"Number of worker threads (default:#{nTh})") do |num|
18
18
  options[:workers] = num.to_i.abs
19
19
  end
20
- opts.on('-d','--debug','Print output from workers on stdout') do
21
- options[:debug] = true
20
+ opts.on('-D','--no-debug','subpress output from workers') do
21
+ options[:debug] = false
22
+ end
23
+ opts.on('-v','--version','Print version nummer') do
24
+ puts '1.0.9'
25
+ exit
22
26
  end
23
27
  # This displays the help screen, all programs are
24
28
  # assumed to have this option.
@@ -39,7 +43,7 @@ ARGV.each do|f|
39
43
  # read file line per line
40
44
  lines = File.open(f).readlines.map(&:chomp)
41
45
  q = SystemJobs.new(options[:workers],options[:debug])
42
- puts "Run with #{q.workers} threads"
46
+ puts "Run with #{q.workers} threads" if options[:debug]
43
47
  lines.each {|line| q.push(line) }
44
48
  q.run
45
49
  end
data/gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = "jobQueue"
5
- s.version = '1.0.8'
5
+ s.version = '1.0.9'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.bindir = 'bin'
8
8
  s.files = ["lib/jobqueue.rb","bin/prun.rb"] + ["gemspec","LICENSE","README.rdoc"]
@@ -1,6 +1,5 @@
1
- #!/usr/bin/env ruby
2
1
  require 'thread'
3
- require 'pp'
2
+ require 'open3'
4
3
  # ==============================================================================
5
4
  # Author: Ralf Mueller, ralf.mueller@zmaw.de
6
5
  # suggestions from Robert Klemme (https://www.ruby-forum.com/topic/68001#86298)
@@ -96,7 +95,12 @@ class SystemJobs < JobQueue
96
95
  @threads = (1..@workers).map {|i|
97
96
  Thread.new(@queue,@debug) {|q,dbg|
98
97
  until ( q == ( task = q.deq ) )
99
- ret = IO.popen(task.first).read
98
+ _, stdout, stderr, _ = Open3.popen3(task.first)
99
+
100
+ # Create a thread to read from each stream
101
+ [stdout,stderr].map {|stdio|
102
+ Thread.new { puts $_ until stdio.gets.nil? }
103
+ }.each {|t| t.join} if dbg
100
104
  end
101
105
  }
102
106
  }
@@ -212,7 +212,7 @@ class TestJobQueue < Test::Unit::TestCase
212
212
  script.close
213
213
  filename = script.path
214
214
  puts IO.popen("cat "+script.path).read
215
- cmd = lambda {|np,script| "ruby -rubygems ./bin/prun.rb -d -j #{np} #{script}"}
215
+ cmd = lambda {|np,script| "ruby -rubygems ./bin/prun.rb -j #{np} #{script}"}
216
216
 
217
217
  # test in debug mode
218
218
  tstart = Time.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobQueue
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-19 00:00:00.000000000 Z
12
+ date: 2013-03-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Run Shell commands or Ruby methods in parallel
15
15
  email: stark.dreamdetective@gmail.com