scout-gear 10.10.1 → 10.11.0
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/scout/work_queue/worker.rb +9 -3
- data/lib/scout/work_queue.rb +20 -3
- data/lib/scout/workflow/task/inputs.rb +2 -2
- data/scout-gear.gemspec +3 -3
- data/test/scout/test_work_queue.rb +41 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f8aff3d8f7e3fc85a03340ec43ac1544b724a20de30e1607e1b07f6812099c7
|
|
4
|
+
data.tar.gz: 75685ce3a5868a2f21f71527fbbc69f46f758d279d393c2d1fc48c64ffa786f0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e20ac4a92bfed76ea6967cc3441ebf0bd33f72203592dec178f88edb094e30be01f2fc84e749f002be5987baffd2e10a7a0b9653bc0ef14c04da31633306f89
|
|
7
|
+
data.tar.gz: 12bc3dbcad9f8ba28c6472fadc6f525813a02f4a631010422f01984753f39e429e5ea8cf958bc2e160ccd11d6bc8a798251b32043b1b63fc4cc9960d2ec9281c
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
10.
|
|
1
|
+
10.11.0
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
class WorkQueue
|
|
2
2
|
class Worker
|
|
3
|
+
EXIT_STATUS=246
|
|
4
|
+
SIGNAL='ABRT'
|
|
5
|
+
|
|
3
6
|
attr_accessor :pid, :ignore_ouput, :queue_id
|
|
4
7
|
def initialize(ignore_ouput = false)
|
|
5
8
|
@ignore_output = ignore_ouput
|
|
@@ -15,7 +18,10 @@ class WorkQueue
|
|
|
15
18
|
|
|
16
19
|
def run
|
|
17
20
|
@pid = Process.fork do
|
|
18
|
-
Signal.trap(
|
|
21
|
+
Signal.trap(SIGNAL) do
|
|
22
|
+
Kernel.exit! EXIT_STATUS
|
|
23
|
+
end
|
|
24
|
+
Signal.trap('INT') do
|
|
19
25
|
Kernel.exit! -1
|
|
20
26
|
end
|
|
21
27
|
Log.low "Worker start #{worker_id}"
|
|
@@ -46,7 +52,7 @@ class WorkQueue
|
|
|
46
52
|
begin
|
|
47
53
|
output.write WorkerException.new($!, Process.pid)
|
|
48
54
|
ensure
|
|
49
|
-
exit
|
|
55
|
+
exit EXIT_STATUS
|
|
50
56
|
end
|
|
51
57
|
end
|
|
52
58
|
exit 0
|
|
@@ -56,7 +62,7 @@ class WorkQueue
|
|
|
56
62
|
def abort
|
|
57
63
|
begin
|
|
58
64
|
Log.medium "Aborting worker #{worker_id}"
|
|
59
|
-
Process.kill
|
|
65
|
+
Process.kill SIGNAL, @pid
|
|
60
66
|
rescue Errno::ECHILD
|
|
61
67
|
rescue Errno::ESRCH
|
|
62
68
|
end
|
data/lib/scout/work_queue.rb
CHANGED
|
@@ -71,13 +71,15 @@ class WorkQueue
|
|
|
71
71
|
Thread.current.report_on_exception = false
|
|
72
72
|
Thread.current["name"] = "Output reader #{queue_id}"
|
|
73
73
|
@done_workers ||= []
|
|
74
|
-
while true
|
|
75
|
-
|
|
74
|
+
#while true
|
|
75
|
+
# obj = @output.read
|
|
76
|
+
while obj = @output.read
|
|
76
77
|
if DoneProcessing === obj
|
|
77
78
|
|
|
78
79
|
done = @worker_mutex.synchronize do
|
|
79
80
|
Log.low "Worker #{obj.pid} from #{queue_id} done"
|
|
80
81
|
@done_workers << obj.pid
|
|
82
|
+
#@closed && (@workers.empty? || @workers.length == @removed_workers.length + @done_workers.length)
|
|
81
83
|
@closed && @done_workers.length == @removed_workers.length + @workers.length
|
|
82
84
|
end
|
|
83
85
|
|
|
@@ -113,14 +115,29 @@ class WorkQueue
|
|
|
113
115
|
break if @worker_mutex.synchronize{ @workers.empty? }
|
|
114
116
|
threads = @workers.collect do |w|
|
|
115
117
|
t = Thread.new do
|
|
118
|
+
Thread.report_on_exception = false
|
|
116
119
|
Thread.current["name"] = "Worker waiter #{queue_id} worker #{w.pid}"
|
|
117
120
|
pid, status = Process.wait2 w.pid
|
|
118
121
|
remove_worker(pid) if pid
|
|
122
|
+
#@output.write WorkerException.new(Exception.new("Worker ended with status #{status.exitstatus}"), pid) unless status.success?
|
|
123
|
+
raise Exception.new("Worker #{pid} ended with status #{status.exitstatus}") unless (status.success? || status.exitstatus == WorkQueue::Worker::EXIT_STATUS)
|
|
119
124
|
end
|
|
120
125
|
Thread.pass until t["name"]
|
|
121
126
|
t
|
|
122
127
|
end
|
|
123
|
-
|
|
128
|
+
exceptions = []
|
|
129
|
+
threads.each do |t|
|
|
130
|
+
begin
|
|
131
|
+
t.join
|
|
132
|
+
rescue
|
|
133
|
+
exceptions << $!
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
raise exceptions.first if exceptions.any?
|
|
138
|
+
if @workers.empty? && ! @closed
|
|
139
|
+
@output.write DoneProcessing.new
|
|
140
|
+
end
|
|
124
141
|
end
|
|
125
142
|
end
|
|
126
143
|
|
|
@@ -91,7 +91,7 @@ module Task
|
|
|
91
91
|
basename = File.basename(orig_file)
|
|
92
92
|
digest = Misc.digest(orig_file)
|
|
93
93
|
if basename.include? '.'
|
|
94
|
-
basename.sub
|
|
94
|
+
basename = basename.sub(/(\.[^.]+(?:\.[^.]+)*)?$/, "-#{digest}\\1")
|
|
95
95
|
else
|
|
96
96
|
basename += "-#{digest}"
|
|
97
97
|
end
|
|
@@ -158,7 +158,7 @@ module Task
|
|
|
158
158
|
elsif filename.end_with?('.as_path')
|
|
159
159
|
value = Open.read(filename).strip
|
|
160
160
|
Path.setup value
|
|
161
|
-
elsif (options && (options[:noload] || options[:stream] || options[:nofile] || options[:asfile]))
|
|
161
|
+
elsif type.to_s == 'file' || (options && (options[:noload] || options[:stream] || options[:nofile] || options[:asfile]))
|
|
162
162
|
filename
|
|
163
163
|
else
|
|
164
164
|
Persist.load(filename, type)
|
data/scout-gear.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: scout-gear 10.
|
|
5
|
+
# stub: scout-gear 10.11.0 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "scout-gear".freeze
|
|
9
|
-
s.version = "10.
|
|
9
|
+
s.version = "10.11.0".freeze
|
|
10
10
|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
12
12
|
s.require_paths = ["lib".freeze]
|
|
@@ -282,7 +282,7 @@ Gem::Specification.new do |s|
|
|
|
282
282
|
]
|
|
283
283
|
s.homepage = "http://github.com/mikisvaz/scout-gear".freeze
|
|
284
284
|
s.licenses = ["MIT".freeze]
|
|
285
|
-
s.rubygems_version = "3.7.
|
|
285
|
+
s.rubygems_version = "3.7.2".freeze
|
|
286
286
|
s.summary = "basic gear for scouts".freeze
|
|
287
287
|
|
|
288
288
|
s.specification_version = 4
|
|
@@ -172,5 +172,46 @@ class TestWorkQueue < Test::Unit::TestCase
|
|
|
172
172
|
end
|
|
173
173
|
end
|
|
174
174
|
end
|
|
175
|
+
|
|
176
|
+
def test_processed_killed
|
|
177
|
+
num = 10
|
|
178
|
+
reps = 3000
|
|
179
|
+
|
|
180
|
+
q = WorkQueue.new num do |obj|
|
|
181
|
+
sleep 0.01
|
|
182
|
+
[Process.pid.to_s, obj.to_s] * " "
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
res = []
|
|
186
|
+
q.process do |out|
|
|
187
|
+
res << out
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
t = Thread.new do
|
|
191
|
+
Thread.current.report_on_exception = false
|
|
192
|
+
Thread.current["name"] = "queue writer"
|
|
193
|
+
reps.times do |i|
|
|
194
|
+
q.write i
|
|
195
|
+
end
|
|
196
|
+
q.close
|
|
197
|
+
end
|
|
198
|
+
Thread.pass until t["name"]
|
|
199
|
+
|
|
200
|
+
sleep 1
|
|
201
|
+
|
|
202
|
+
assert_raise Exception do
|
|
203
|
+
Process.kill 'INT', q.workers.first.pid
|
|
204
|
+
begin
|
|
205
|
+
t.join
|
|
206
|
+
q.join(false)
|
|
207
|
+
rescue Exception
|
|
208
|
+
t.raise($!)
|
|
209
|
+
raise $!
|
|
210
|
+
ensure
|
|
211
|
+
t.join
|
|
212
|
+
q.clean
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
end
|
|
175
216
|
end
|
|
176
217
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scout-gear
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 10.
|
|
4
|
+
version: 10.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Miguel Vazquez
|
|
@@ -380,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
380
380
|
- !ruby/object:Gem::Version
|
|
381
381
|
version: '0'
|
|
382
382
|
requirements: []
|
|
383
|
-
rubygems_version: 3.7.
|
|
383
|
+
rubygems_version: 3.7.2
|
|
384
384
|
specification_version: 4
|
|
385
385
|
summary: basic gear for scouts
|
|
386
386
|
test_files: []
|