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 +1 -1
- data/bin/prun.rb +8 -4
- data/gemspec +1 -1
- data/lib/jobqueue.rb +7 -3
- data/test/test_jobqueue.rb +1 -1
- metadata +2 -2
data/LICENSE
CHANGED
data/bin/prun.rb
CHANGED
|
@@ -9,7 +9,7 @@ require 'jobqueue'
|
|
|
9
9
|
# ==============================================================================
|
|
10
10
|
|
|
11
11
|
nTh = SystemJobs.maxnumber_of_processors
|
|
12
|
-
options = {:workers => nTh,:debug =>
|
|
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('-
|
|
21
|
-
options[:debug] =
|
|
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
data/lib/jobqueue.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
1
|
require 'thread'
|
|
3
|
-
require '
|
|
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
|
-
|
|
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
|
}
|
data/test/test_jobqueue.rb
CHANGED
|
@@ -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 -
|
|
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.
|
|
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:
|
|
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
|