rbbt-util 5.23.5 → 5.23.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/persist.rb +6 -2
- data/lib/rbbt/tsv/parallel/traverse.rb +4 -6
- data/lib/rbbt/util/concurrency/processes.rb +117 -107
- data/lib/rbbt/util/concurrency/processes/socket.rb +1 -1
- data/lib/rbbt/util/concurrency/processes/worker.rb +48 -17
- data/lib/rbbt/util/log.rb +2 -2
- data/lib/rbbt/util/log/progress.rb +15 -20
- data/lib/rbbt/util/misc/concurrent_stream.rb +4 -5
- data/lib/rbbt/util/misc/development.rb +6 -0
- data/lib/rbbt/util/misc/exceptions.rb +8 -1
- data/lib/rbbt/util/misc/pipes.rb +1 -1
- data/share/rbbt_commands/workflow/task +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c71bcff349d90d7b342c381f84bc4958cc5f733
|
4
|
+
data.tar.gz: a78929b585bb9a6187e6b45bd31e825ba2000907
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 236bd1122fd5ac49d4bba5fb86eb5cf48123292703509bb7deaf323930f8550a19a30a3dd7db2e4cfa2f72b93191bab211548d5569722b3d0299a05703221538
|
7
|
+
data.tar.gz: 21623006af00e24c2912b3ed5d7f2dd41144bc59cd0ae5b0cd5941e805ecdc05584cec9399b294768c5e81aaf628e35676c464097d9884bb608207dba4dcc611
|
data/lib/rbbt/persist.rb
CHANGED
@@ -209,14 +209,17 @@ module Persist
|
|
209
209
|
rescue Exception
|
210
210
|
Log.medium "Persist stream thread exception: #{ Log.color :blue, path }"
|
211
211
|
file.abort if file.respond_to? :abort
|
212
|
-
parent.raise $!
|
212
|
+
#parent.raise $!
|
213
213
|
raise $!
|
214
214
|
rescue Exception
|
215
215
|
Log.exception $!
|
216
216
|
raise $!
|
217
217
|
end
|
218
218
|
end
|
219
|
-
|
219
|
+
|
220
|
+
threads = [saver_thread]
|
221
|
+
threads += stream.threads if stream.respond_to?(:threads) && stream.threads
|
222
|
+
ConcurrentStream.setup(out, :threads => threads, :filename => path)
|
220
223
|
|
221
224
|
out.callback = callback
|
222
225
|
out.abort_callback = abort_callback
|
@@ -225,6 +228,7 @@ module Persist
|
|
225
228
|
stream.callback = callback
|
226
229
|
stream.abort_callback = abort_callback
|
227
230
|
|
231
|
+
|
228
232
|
out
|
229
233
|
end
|
230
234
|
|
@@ -349,7 +349,6 @@ module TSV
|
|
349
349
|
end
|
350
350
|
|
351
351
|
q.join
|
352
|
-
q.clean
|
353
352
|
nil
|
354
353
|
end
|
355
354
|
|
@@ -375,8 +374,8 @@ module TSV
|
|
375
374
|
|
376
375
|
rescue Interrupt, Aborted
|
377
376
|
error = true
|
378
|
-
q.abort
|
379
377
|
Log.low{"Aborted traversal in CPUs for #{stream_name(obj) || Misc.fingerprint(obj)}: #{$!.backtrace*","}"}
|
378
|
+
q.abort
|
380
379
|
stream = obj_stream(obj)
|
381
380
|
stream.abort if stream.respond_to? :abort
|
382
381
|
stream = obj_stream(options[:into])
|
@@ -384,15 +383,14 @@ module TSV
|
|
384
383
|
raise "Traversal aborted"
|
385
384
|
rescue Exception
|
386
385
|
error = true
|
386
|
+
Log.low{"Exception during traversal in CPUs for #{stream_name(obj) || Misc.fingerprint(obj)}: #{$!.message}"}
|
387
387
|
q.abort
|
388
|
-
Log.low "Exception during traversal in CPUs for #{stream_name(obj) || Misc.fingerprint(obj)}: #{$!.message}"
|
389
388
|
stream = obj_stream(obj)
|
390
389
|
stream.abort if stream.respond_to? :abort
|
391
390
|
stream = obj_stream(options[:into])
|
392
391
|
stream.abort if stream.respond_to? :abort
|
393
392
|
raise $!
|
394
393
|
ensure
|
395
|
-
q.clean
|
396
394
|
if bar
|
397
395
|
Log::ProgressBar.remove_bar(bar, error)
|
398
396
|
end
|
@@ -509,13 +507,13 @@ module TSV
|
|
509
507
|
def self.traverse_stream(obj, threads = nil, cpus = nil, options = {}, &block)
|
510
508
|
into = options[:into]
|
511
509
|
|
512
|
-
thread = Thread.new
|
510
|
+
thread = Thread.new do
|
513
511
|
begin
|
514
512
|
traverse_run(obj, threads, cpus, options, &block)
|
515
513
|
into.close if into.respond_to?(:close) and not (into.respond_to? :closed? and into.closed?)
|
516
514
|
rescue Exception
|
517
515
|
abort_stream obj
|
518
|
-
|
516
|
+
abort_stream into
|
519
517
|
raise $!
|
520
518
|
end
|
521
519
|
end
|
@@ -30,49 +30,17 @@ class RbbtProcessQueue
|
|
30
30
|
|
31
31
|
@callback_queue = RbbtProcessSocket.new
|
32
32
|
|
33
|
-
@callback_thread = Thread.new(Thread.current) do |parent|
|
34
|
-
begin
|
35
|
-
loop do
|
36
|
-
p = @callback_queue.pop unless @callback_queue.cleaned
|
37
|
-
|
38
|
-
if Exception === p or (Array === p and Exception === p.first)
|
39
|
-
e = Array === p ? p.first : p
|
40
|
-
Log.warn "Callback recieved exception from worker: #{e.message}" unless Aborted === e or ClosedStream === e
|
41
|
-
raise e
|
42
|
-
end
|
43
|
-
|
44
|
-
if @callback.arity == 0
|
45
|
-
@callback.call
|
46
|
-
else
|
47
|
-
@callback.call p
|
48
|
-
end
|
49
|
-
end
|
50
|
-
rescue ClosedStream
|
51
|
-
rescue Aborted
|
52
|
-
Log.warn "Callback thread aborted"
|
53
|
-
self._abort
|
54
|
-
raise $!
|
55
|
-
rescue Exception
|
56
|
-
Log.warn "Exception captured in callback: #{$!.message}"
|
57
|
-
self._abort
|
58
|
-
raise $!
|
59
|
-
ensure
|
60
|
-
|
61
|
-
@callback_queue.sread.close unless @callback_queue.sread.closed?
|
62
|
-
end
|
63
|
-
end
|
64
33
|
else
|
65
34
|
@callback, @callback_queue, @callback_thread = nil, nil, nil
|
66
35
|
end
|
67
36
|
end
|
68
37
|
|
69
|
-
def
|
70
|
-
@init_block = block
|
71
|
-
|
38
|
+
def init_master
|
72
39
|
RbbtSemaphore.wait_semaphore(@sem)
|
73
40
|
@master_pid = Process.fork do
|
74
41
|
@close_up = false
|
75
42
|
processes_initiated = false
|
43
|
+
processes = []
|
76
44
|
process_mutex = Mutex.new
|
77
45
|
|
78
46
|
Signal.trap(CLOSE_SIGNAL) do
|
@@ -103,24 +71,22 @@ class RbbtProcessQueue
|
|
103
71
|
end
|
104
72
|
|
105
73
|
Signal.trap(ABORT_SIGNAL) do
|
106
|
-
|
107
|
-
|
108
|
-
end
|
74
|
+
@abort_monitor = true
|
75
|
+
@monitor_thread.raise Aborted if @monitor_thread && @monitor_thread.alive?
|
109
76
|
end
|
110
77
|
|
111
78
|
if @callback_queue
|
112
|
-
Misc.purge_pipes(@queue.swrite, @queue.sread, @callback_queue.swrite
|
79
|
+
Misc.purge_pipes(@queue.swrite, @queue.sread, @callback_queue.swrite)
|
113
80
|
else
|
114
81
|
Misc.purge_pipes(@queue.swrite, @queue.sread)
|
115
82
|
end
|
116
83
|
|
117
84
|
@total = 0
|
118
85
|
@count = 0
|
119
|
-
processes = []
|
120
86
|
|
121
87
|
@manager_thread = Thread.new do
|
122
|
-
begin
|
123
88
|
while true
|
89
|
+
break if processes_initiated && processes.empty? && (@monitor_thread && ! @monitor_thread.alive?)
|
124
90
|
begin
|
125
91
|
Thread.current["working"] = true
|
126
92
|
if @close_up
|
@@ -171,14 +137,10 @@ class RbbtProcessQueue
|
|
171
137
|
Log.low "Aborting manager thread #{Process.pid}"
|
172
138
|
raise Aborted
|
173
139
|
rescue Exception
|
174
|
-
Log.exception $!
|
175
140
|
raise Exception
|
176
141
|
end
|
177
142
|
end
|
178
|
-
|
179
|
-
Log.exception $!
|
180
|
-
raise $!
|
181
|
-
end
|
143
|
+
Log.low "Manager thred stopped #{Process.pid}"
|
182
144
|
end
|
183
145
|
|
184
146
|
@callback_queue.close_read if @callback_queue
|
@@ -195,43 +157,84 @@ class RbbtProcessQueue
|
|
195
157
|
@monitor_thread = Thread.new do
|
196
158
|
begin
|
197
159
|
while processes.any?
|
198
|
-
|
160
|
+
raise Aborted if @abort_monitor
|
161
|
+
processes[0].join
|
162
|
+
Log.debug "Joined process #{processes[0].pid} of queue #{Process.pid}"
|
199
163
|
processes.shift
|
200
164
|
end
|
165
|
+
Log.low "All processes completed #{Process.pid}"
|
201
166
|
rescue Aborted
|
202
|
-
Log.
|
203
|
-
processes.each{|p|
|
167
|
+
Log.low "Aborting process monitor #{Process.pid}"
|
168
|
+
processes.each{|p| p.abort_and_join}
|
169
|
+
Log.low "Processes aborted #{Process.pid}"
|
204
170
|
processes.clear
|
205
171
|
|
206
|
-
@
|
207
|
-
|
172
|
+
@manager_thread.raise Aborted if @manager_thread.alive?
|
173
|
+
raise Aborted, "Aborted monitor thread"
|
208
174
|
rescue Exception
|
209
|
-
Log.
|
175
|
+
Log.low "Process monitor exception [#{Process.pid}]: #{$!.message}"
|
210
176
|
processes.each{|p| p.abort_and_join}
|
177
|
+
Log.low "Processes aborted #{Process.pid}"
|
211
178
|
processes.clear
|
212
179
|
|
213
|
-
@
|
214
|
-
|
180
|
+
@manager_thread.raise $! if @manager_thread.alive?
|
181
|
+
raise Aborted, "Aborted monitor thread with exception"
|
215
182
|
end
|
216
183
|
end
|
217
184
|
|
218
185
|
RbbtSemaphore.post_semaphore(@sem)
|
219
186
|
|
220
187
|
begin
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
188
|
+
@monitor_thread.join
|
189
|
+
@manager_thread.raise TryAgain if @manager_thread.alive?
|
190
|
+
@manager_thread.join
|
191
|
+
@callback_queue.push ClosedStream.new if @callback_queue
|
225
192
|
rescue Exception
|
226
|
-
|
193
|
+
Kernel.exit -1
|
227
194
|
end
|
228
195
|
|
229
|
-
Kernel.exit
|
196
|
+
Kernel.exit 0
|
230
197
|
end
|
231
198
|
|
232
|
-
Log.info "Cpu process (#{num_processes}) started with master: #{@master_pid}"
|
233
|
-
|
234
199
|
@queue.close_read
|
200
|
+
Log.info "Cpu process (#{num_processes}) started with master: #{@master_pid}"
|
201
|
+
end
|
202
|
+
|
203
|
+
def init(&block)
|
204
|
+
@init_block = block
|
205
|
+
|
206
|
+
init_master
|
207
|
+
|
208
|
+
RbbtSemaphore.synchronize(@sem) do
|
209
|
+
@callback_thread = Thread.new do
|
210
|
+
begin
|
211
|
+
loop do
|
212
|
+
p = @callback_queue.pop unless @callback_queue.cleaned
|
213
|
+
|
214
|
+
if Exception === p or (Array === p and Exception === p.first)
|
215
|
+
e = Array === p ? p.first : p
|
216
|
+
Log.low "Callback recieved exception from worker: #{e.message}" unless Aborted === e or ClosedStream === e
|
217
|
+
raise e
|
218
|
+
end
|
219
|
+
|
220
|
+
if @callback.arity == 0
|
221
|
+
@callback.call
|
222
|
+
else
|
223
|
+
@callback.call p
|
224
|
+
end
|
225
|
+
end
|
226
|
+
rescue ClosedStream
|
227
|
+
Log.low "Callback thread closing"
|
228
|
+
rescue Aborted
|
229
|
+
Log.low "Callback thread aborted"
|
230
|
+
raise $!
|
231
|
+
rescue Exception
|
232
|
+
Log.low "Exception captured in callback: #{$!.message}"
|
233
|
+
raise $!
|
234
|
+
end
|
235
|
+
end if @callback_queue
|
236
|
+
end
|
237
|
+
|
235
238
|
end
|
236
239
|
|
237
240
|
def add_process
|
@@ -242,78 +245,84 @@ class RbbtProcessQueue
|
|
242
245
|
Process.kill :USR2, @master_pid
|
243
246
|
end
|
244
247
|
|
245
|
-
def close_callback
|
246
|
-
return unless @callback_thread.alive?
|
247
|
-
begin
|
248
|
-
t = Thread.new do
|
249
|
-
@callback_queue.push ClosedStream.new
|
250
|
-
end
|
251
|
-
rescue Exception
|
252
|
-
Log.warn "Error closing callback: #{$!.message}"
|
253
|
-
end
|
254
|
-
@callback_thread.join if @callback_thread && @callback_thread.alive?
|
255
|
-
t.join if t && t.alive?
|
256
|
-
end
|
257
|
-
|
258
248
|
def _join
|
259
|
-
error =
|
249
|
+
error = :redo
|
260
250
|
begin
|
261
|
-
pid, status = Process.waitpid2 @master_pid
|
262
|
-
error =
|
263
|
-
raise ProcessFailed
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
251
|
+
pid, @status = Process.waitpid2 @master_pid unless @status
|
252
|
+
error = true unless @status.success?
|
253
|
+
raise ProcessFailed.new @master_pid unless @status.success?
|
254
|
+
@callback_thread.join
|
255
|
+
error = false
|
256
|
+
rescue Aborted, Interrupt
|
257
|
+
Log.exception $!
|
258
|
+
self.abort
|
259
|
+
error = true
|
260
|
+
Log.high "Process queue #{@master_pid} aborted"
|
261
|
+
retry
|
262
|
+
rescue Errno::ESRCH, Errno::ECHILD
|
263
|
+
retry if Misc.pid_exists? @master_pid
|
264
|
+
error = ! @status.success?
|
265
|
+
rescue ProcessFailed
|
268
266
|
rescue Exception
|
269
|
-
Log.
|
270
|
-
|
267
|
+
Log.exception $!
|
268
|
+
retry
|
271
269
|
ensure
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
270
|
+
begin
|
271
|
+
begin
|
272
|
+
self.abort
|
273
|
+
ensure
|
274
|
+
_join
|
275
|
+
end if error == :redo
|
276
|
+
|
277
|
+
begin
|
278
|
+
@callback_thread.join
|
279
|
+
rescue Exception
|
280
|
+
end
|
281
|
+
|
282
|
+
Log.high "Joining #{"(error) " if error}#{@master_pid} #{@join}"
|
283
|
+
begin
|
284
|
+
if @join
|
285
|
+
if @join.arity == 1
|
286
|
+
@join.call(error)
|
287
|
+
else
|
288
|
+
@join.call
|
289
|
+
end
|
290
|
+
end
|
279
291
|
end
|
292
|
+
ensure
|
293
|
+
self.clean
|
280
294
|
end
|
281
295
|
end
|
282
|
-
|
283
296
|
end
|
284
297
|
|
285
|
-
def
|
298
|
+
def close_up_queue
|
286
299
|
begin
|
287
300
|
RbbtSemaphore.synchronize(@sem) do
|
288
301
|
Process.kill CLOSE_SIGNAL, @master_pid
|
289
302
|
end
|
290
303
|
rescue Errno::ECHILD, Errno::ESRCH
|
291
|
-
Log.debug "Cannot kill #{@master_pid}: #{$!.message}"
|
292
|
-
end
|
304
|
+
Log.debug "Cannot kill (CLOSE) #{@master_pid}: #{$!.message}"
|
305
|
+
end if Misc.pid_exists? @master_pid
|
306
|
+
end
|
293
307
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
@queue.swrite.close unless @queue.swrite.closed?
|
299
|
-
end
|
300
|
-
#@callback_thread.join if @callback_thread
|
301
|
-
self.clean
|
308
|
+
def join
|
309
|
+
close_up_queue
|
310
|
+
|
311
|
+
_join
|
302
312
|
end
|
303
313
|
|
304
314
|
def _abort
|
305
315
|
begin
|
306
316
|
Process.kill ABORT_SIGNAL, @master_pid
|
307
|
-
pid, status = Process.waitpid2 @master_pid
|
308
317
|
rescue Errno::ECHILD, Errno::ESRCH
|
309
|
-
Log.
|
318
|
+
Log.debug "Cannot abort #{@master_pid}: #{$!.message}"
|
310
319
|
end
|
311
320
|
end
|
312
321
|
|
313
322
|
def abort
|
314
323
|
_abort
|
315
324
|
(@callback_thread.raise(Aborted.new); @callback_thread.join) if @callback_thread and @callback_thread.alive?
|
316
|
-
|
325
|
+
@aborted = true
|
317
326
|
end
|
318
327
|
|
319
328
|
def clean
|
@@ -323,7 +332,8 @@ class RbbtProcessQueue
|
|
323
332
|
|
324
333
|
ensure
|
325
334
|
@queue.clean if @queue
|
326
|
-
|
335
|
+
#@callback_thread.push ClosedStream if @callback_thread && @callback_thread.alive?
|
336
|
+
@callback_queue.clean if @queue
|
327
337
|
end
|
328
338
|
end
|
329
339
|
|
@@ -21,7 +21,7 @@ class RbbtProcessQueue
|
|
21
21
|
@cleaned = true
|
22
22
|
@sread.close unless @sread.closed?
|
23
23
|
@swrite.close unless @swrite.closed?
|
24
|
-
Log.
|
24
|
+
Log.low "Destroying socket semaphores: #{[@key] * ", "}"
|
25
25
|
RbbtSemaphore.delete_semaphore(@write_sem)
|
26
26
|
RbbtSemaphore.delete_semaphore(@read_sem)
|
27
27
|
end
|
@@ -30,7 +30,6 @@ class RbbtProcessQueue
|
|
30
30
|
@abort = false
|
31
31
|
Signal.trap(20){
|
32
32
|
@abort = true
|
33
|
-
raise Aborted
|
34
33
|
}
|
35
34
|
|
36
35
|
loop do
|
@@ -64,8 +63,10 @@ class RbbtProcessQueue
|
|
64
63
|
retry unless @stop
|
65
64
|
Log.high "Worker #{Process.pid} leaving"
|
66
65
|
rescue Exception
|
67
|
-
|
68
|
-
|
66
|
+
begin
|
67
|
+
@callback_queue.push($!) if @callback_queue
|
68
|
+
rescue
|
69
|
+
end
|
69
70
|
Kernel.exit! -1
|
70
71
|
ensure
|
71
72
|
@callback_queue.close_write if @callback_queue
|
@@ -119,6 +120,35 @@ class RbbtProcessQueue
|
|
119
120
|
sleep 0.1
|
120
121
|
end
|
121
122
|
|
123
|
+
@current = nil
|
124
|
+
Signal.trap(:INT){
|
125
|
+
begin
|
126
|
+
Process.kill :INT, @current if @current
|
127
|
+
rescue Errno::ESRCH, Errno::ECHILD
|
128
|
+
end
|
129
|
+
}
|
130
|
+
|
131
|
+
Signal.trap(:USR1){
|
132
|
+
begin
|
133
|
+
Process.kill :USR1, @current if @current
|
134
|
+
rescue Errno::ESRCH, Errno::ECHILD
|
135
|
+
end
|
136
|
+
}
|
137
|
+
|
138
|
+
Signal.trap(:USR2){
|
139
|
+
begin
|
140
|
+
Process.kill :USR2, @current if @current
|
141
|
+
rescue Errno::ESRCH, Errno::ECHILD
|
142
|
+
end
|
143
|
+
}
|
144
|
+
|
145
|
+
Signal.trap(20){
|
146
|
+
begin
|
147
|
+
Process.kill 20, @current if @current
|
148
|
+
rescue Errno::ESRCH, Errno::ECHILD
|
149
|
+
end
|
150
|
+
}
|
151
|
+
|
122
152
|
@current = Process.fork do
|
123
153
|
run
|
124
154
|
end
|
@@ -135,12 +165,11 @@ class RbbtProcessQueue
|
|
135
165
|
Log.high "Worker #{Process.pid} respawning from #{@prev} to #{@current}"
|
136
166
|
end
|
137
167
|
rescue Aborted, Interrupt
|
138
|
-
Log.
|
168
|
+
Log.high "Worker #{Process.pid} aborted. Current #{@current} #{Misc.pid_exists?(@current) ? "exists" : "does not exist"}"
|
139
169
|
Process.kill "INT", @current if Misc.pid_exists? @current
|
140
170
|
@callback_queue.close_write if @callback_queue
|
141
171
|
Kernel.exit! 0
|
142
172
|
rescue Exception
|
143
|
-
Log.exception $!
|
144
173
|
raise $!
|
145
174
|
ensure
|
146
175
|
@monitor_thread.kill if @monitor_thread
|
@@ -185,10 +214,10 @@ class RbbtProcessQueue
|
|
185
214
|
return unless Misc.pid_exists? @pid
|
186
215
|
begin
|
187
216
|
pid, status = Process.waitpid2 @pid
|
188
|
-
raise ProcessFailed if not status.success?
|
217
|
+
raise ProcessFailed.new @pid if not status.success?
|
189
218
|
rescue Aborted
|
190
219
|
self.abort
|
191
|
-
raise
|
220
|
+
raise Aborted
|
192
221
|
rescue Errno::ESRCH, Errno::ECHILD
|
193
222
|
Log.exception $!
|
194
223
|
rescue ProcessFailed
|
@@ -204,37 +233,39 @@ class RbbtProcessQueue
|
|
204
233
|
begin
|
205
234
|
Process.kill 20, @pid
|
206
235
|
rescue Errno::ESRCH, Errno::ECHILD
|
207
|
-
rescue Exception
|
208
|
-
Log.exception $!
|
209
236
|
end
|
210
237
|
end
|
211
238
|
|
212
239
|
def abort_and_join
|
213
|
-
|
214
|
-
Process.kill 20, @pid
|
215
|
-
rescue Errno::ESRCH, Errno::ECHILD
|
216
|
-
Log.low "Already joined worker #{@pid}"
|
217
|
-
return
|
218
|
-
end
|
240
|
+
self.abort
|
219
241
|
|
242
|
+
begin
|
220
243
|
Misc.insist([0,0.05,0.5,1,2]) do
|
221
244
|
begin
|
222
245
|
pid, status = Process.waitpid2 @pid, Process::WNOHANG
|
223
|
-
raise if status.nil?
|
224
246
|
Log.low "Abort and join of #{@pid}"
|
225
247
|
return
|
248
|
+
rescue Aborted
|
249
|
+
abort
|
250
|
+
raise
|
251
|
+
rescue ProcessFailed
|
252
|
+
Log.low "Abort and join of #{@pid} (ProcessFailed)"
|
253
|
+
return
|
226
254
|
rescue Errno::ESRCH, Errno::ECHILD
|
227
255
|
Log.low "Already joined worker #{@pid}"
|
228
256
|
return
|
229
257
|
end
|
230
258
|
end
|
231
|
-
|
259
|
+
rescue Aborted
|
260
|
+
retry
|
261
|
+
end
|
232
262
|
|
233
263
|
begin
|
234
264
|
Log.low "Forcing abort of #{@pid}"
|
235
265
|
Process.kill 9, @pid
|
236
266
|
pid, status = Process.waitpid2 @pid
|
237
267
|
rescue Errno::ESRCH, Errno::ECHILD
|
268
|
+
Log.low "Force killed worker #{@pid}"
|
238
269
|
end
|
239
270
|
end
|
240
271
|
|
data/lib/rbbt/util/log.rb
CHANGED
@@ -238,7 +238,7 @@ module Log
|
|
238
238
|
def self.exception(e)
|
239
239
|
stack = caller
|
240
240
|
error([e.class.to_s, e.message].compact * ": " )
|
241
|
-
error("BACKTRACE: " << Log.last_caller(stack) << "\n" + color_stack(e.backtrace)*"\n")
|
241
|
+
error("BACKTRACE [#{Process.pid}]: " << Log.last_caller(stack) << "\n" + color_stack(e.backtrace)*"\n")
|
242
242
|
end
|
243
243
|
|
244
244
|
def self.deprecated(m)
|
@@ -265,7 +265,7 @@ module Log
|
|
265
265
|
def self.stack(stack)
|
266
266
|
LOG_MUTEX.synchronize do
|
267
267
|
|
268
|
-
STDERR.puts Log.color :magenta, "Stack trace: " << Log.last_caller(caller)
|
268
|
+
STDERR.puts Log.color :magenta, "Stack trace [#{Process.pid}]: " << Log.last_caller(caller)
|
269
269
|
color_stack(stack).each do |line|
|
270
270
|
STDERR.puts line
|
271
271
|
end
|
@@ -37,29 +37,24 @@ module Log
|
|
37
37
|
return if ENV["RBBT_NO_PROGRESS"] == "true"
|
38
38
|
@ticks += step
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
40
|
+
time = Time.now
|
41
|
+
if @last_time.nil?
|
42
|
+
@last_time = time
|
43
|
+
@last_count = @ticks
|
44
|
+
@start = time
|
45
|
+
return
|
46
|
+
end
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
diff = time - @last_time
|
49
|
+
report and return if diff > @frequency
|
50
|
+
return unless max and max > 0
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
report and return if percent > @last_percent and diff > 0.3
|
59
|
-
rescue Exception
|
60
|
-
Log.warn "Exception during report: " << $!.message
|
61
|
-
Log.exception $!
|
52
|
+
percent = self.percent
|
53
|
+
if @last_percent.nil?
|
54
|
+
@last_percent = percent
|
55
|
+
return
|
62
56
|
end
|
57
|
+
report and return if percent > @last_percent and diff > 0.3
|
63
58
|
end
|
64
59
|
|
65
60
|
def pos(pos)
|
@@ -110,10 +110,9 @@ module ConcurrentStream
|
|
110
110
|
if @callback and not joined?
|
111
111
|
begin
|
112
112
|
@callback.call
|
113
|
-
|
114
|
-
|
113
|
+
ensure
|
114
|
+
@callback = nil
|
115
115
|
end
|
116
|
-
@callback = nil
|
117
116
|
end
|
118
117
|
end
|
119
118
|
|
@@ -135,7 +134,7 @@ module ConcurrentStream
|
|
135
134
|
|
136
135
|
@threads.each do |t|
|
137
136
|
next if t == Thread.current
|
138
|
-
Log.
|
137
|
+
Log.debug "Aborting thread #{t.inspect} with exception: #{exception}"
|
139
138
|
t.raise((exception.nil? ? Aborted.new : exception))
|
140
139
|
end
|
141
140
|
|
@@ -150,7 +149,7 @@ module ConcurrentStream
|
|
150
149
|
t.join unless t == Thread.current
|
151
150
|
rescue Aborted
|
152
151
|
rescue Exception
|
153
|
-
Log.
|
152
|
+
Log.debug "Thread exception: #{$!.message}"
|
154
153
|
end
|
155
154
|
end
|
156
155
|
end
|
@@ -155,6 +155,8 @@ def self.add_libdir(dir=nil)
|
|
155
155
|
rescue StopInsist
|
156
156
|
raise $!.exception
|
157
157
|
rescue Aborted, Interrupt
|
158
|
+
Log.exception $!
|
159
|
+
Log.stack caller
|
158
160
|
if msg
|
159
161
|
Log.warn("Not Insisting after Aborted: #{$!.message} -- #{msg}")
|
160
162
|
else
|
@@ -170,6 +172,10 @@ def self.add_libdir(dir=nil)
|
|
170
172
|
Log.warn("Insisting after exception: #{$!.class} #{$!.message}")
|
171
173
|
end
|
172
174
|
|
175
|
+
Log.stack caller
|
176
|
+
Log.exception $!
|
177
|
+
|
178
|
+
|
173
179
|
if sleep and try > 0
|
174
180
|
sleep sleep
|
175
181
|
sleep = sleep_array.shift || sleep if sleep_array
|
@@ -3,7 +3,14 @@ class ParameterException < RbbtException; end
|
|
3
3
|
class FieldNotFoundError < RbbtException;end
|
4
4
|
class ClosedStream < RbbtException; end
|
5
5
|
|
6
|
-
class ProcessFailed < StandardError;
|
6
|
+
class ProcessFailed < StandardError;
|
7
|
+
def initialize(pid = Process.pid)
|
8
|
+
@pid = pid
|
9
|
+
@msg = "Process #{@pid} failed"
|
10
|
+
super(@msg)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
7
14
|
|
8
15
|
class Aborted < StandardError; end
|
9
16
|
|
data/lib/rbbt/util/misc/pipes.rb
CHANGED
@@ -209,7 +209,7 @@ module Misc
|
|
209
209
|
Log.medium "Tee aborting #{Misc.fingerprint stream}"
|
210
210
|
raise $!
|
211
211
|
rescue Exception
|
212
|
-
stream.abort if stream.respond_to? :abort
|
212
|
+
stream.abort($!) if stream.respond_to? :abort
|
213
213
|
out_pipes.each do |sout|
|
214
214
|
sout.abort if sout.respond_to? :abort
|
215
215
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.23.
|
4
|
+
version: 5.23.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|