rbbt-util 5.23.7 → 5.23.8
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/lib/rbbt/persist.rb +1 -2
- data/lib/rbbt/tsv/parallel/traverse.rb +155 -114
- data/lib/rbbt/util/cmd.rb +10 -4
- data/lib/rbbt/util/concurrency/processes.rb +16 -3
- data/lib/rbbt/util/misc/concurrent_stream.rb +23 -17
- data/lib/rbbt/util/misc/development.rb +0 -6
- data/lib/rbbt/util/misc/pipes.rb +23 -15
- data/lib/rbbt/workflow/step/dependencies.rb +31 -25
- data/lib/rbbt/workflow/step/run.rb +3 -3
- data/test/rbbt/util/misc/test_pipes.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8aaf566bf17aad351fdc54c77e2cff349e23daf
|
4
|
+
data.tar.gz: 393fc23341ab6ecb7b7a01ae408e8ca2dea2ef9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729e28c3ed2a19f84c0b702b3eb62f94b141e64b1b305caa0ae0388409fbdf34e53110922ad0ee6499b4364f5bdba8e1735b1fc491fe7c2dc137e559c66c1189
|
7
|
+
data.tar.gz: 943598ede0e34302e6784b1dc7201165f44ba8dae6e8bed071a828d568bc7d241f1dab49aa3c46c24c4aa77c989d06bb37a483ba4c379d73b789cb8982b2fffe
|
data/lib/rbbt/persist.rb
CHANGED
@@ -197,7 +197,7 @@ module Persist
|
|
197
197
|
def self.tee_stream_thread(stream, path, type, callback = nil, abort_callback = nil, lockfile = nil)
|
198
198
|
file, out = Misc.tee_stream(stream)
|
199
199
|
|
200
|
-
saver_thread = Thread.new
|
200
|
+
saver_thread = Thread.new do
|
201
201
|
begin
|
202
202
|
file.threads = []
|
203
203
|
Thread.current["name"] = "file saver: " + path
|
@@ -209,7 +209,6 @@ 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 $!
|
213
212
|
raise $!
|
214
213
|
rescue Exception
|
215
214
|
Log.exception $!
|
@@ -71,162 +71,200 @@ module TSV
|
|
71
71
|
def self.traverse_tsv(tsv, options = {}, &block)
|
72
72
|
callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
74
|
+
begin
|
75
|
+
error = false
|
76
|
+
if callback
|
77
|
+
bar.init if bar
|
78
|
+
tsv.through options[:key_field], options[:fields] do |k,v|
|
79
|
+
begin
|
80
|
+
callback.call yield(k,v)
|
81
|
+
rescue Exception
|
82
|
+
Log.exception $!
|
83
|
+
raise $!
|
84
|
+
ensure
|
85
|
+
bar.tick if bar
|
86
|
+
end
|
84
87
|
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
88
|
+
else
|
89
|
+
bar.init if bar
|
90
|
+
tsv.through options[:key_field], options[:fields] do |k,v|
|
91
|
+
begin
|
92
|
+
yield k,v
|
93
|
+
ensure
|
94
|
+
bar.tick if bar
|
95
|
+
end
|
93
96
|
end
|
94
97
|
end
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
+
rescue
|
99
|
+
Log.exception $!
|
100
|
+
error = true
|
101
|
+
raise $!
|
102
|
+
ensure
|
103
|
+
Log::ProgressBar.remove_bar(bar) if bar
|
104
|
+
join.call(error) if join
|
105
|
+
end
|
98
106
|
end
|
99
107
|
|
100
108
|
def self.traverse_hash(hash, options = {}, &block)
|
101
109
|
callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
102
110
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
111
|
+
begin
|
112
|
+
error = false
|
113
|
+
if callback
|
114
|
+
bar.init if bar
|
115
|
+
hash.each do |k,v|
|
116
|
+
begin
|
117
|
+
callback.call yield(k,v)
|
118
|
+
ensure
|
119
|
+
bar.tick if bar
|
120
|
+
end
|
110
121
|
end
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
122
|
+
else
|
123
|
+
bar.init if bar
|
124
|
+
hash.each do |k,v|
|
125
|
+
begin
|
126
|
+
yield k,v
|
127
|
+
ensure
|
128
|
+
bar.tick if bar
|
129
|
+
end
|
119
130
|
end
|
120
131
|
end
|
132
|
+
rescue
|
133
|
+
error = true
|
134
|
+
raise $!
|
135
|
+
ensure
|
136
|
+
Log::ProgressBar.remove_bar(bar) if bar
|
137
|
+
join.call(error) if join
|
121
138
|
end
|
122
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
123
|
-
join.call if join
|
124
139
|
end
|
125
140
|
|
126
141
|
def self.traverse_array(array, options = {}, &block)
|
127
142
|
callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
128
143
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
144
|
+
begin
|
145
|
+
error = false
|
146
|
+
if callback
|
147
|
+
bar.init if bar
|
148
|
+
array.each do |e|
|
149
|
+
begin
|
150
|
+
callback.call yield(e)
|
151
|
+
ensure
|
152
|
+
bar.tick if bar
|
153
|
+
end
|
136
154
|
end
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
155
|
+
else
|
156
|
+
bar.init if bar
|
157
|
+
array.each do |e|
|
158
|
+
begin
|
159
|
+
yield e
|
160
|
+
rescue Exception
|
161
|
+
Log.exception $!
|
162
|
+
raise $!
|
163
|
+
ensure
|
164
|
+
bar.tick if bar
|
165
|
+
end
|
148
166
|
end
|
149
167
|
end
|
168
|
+
|
169
|
+
rescue
|
170
|
+
error = true
|
171
|
+
raise $!
|
172
|
+
ensure
|
173
|
+
Log::ProgressBar.remove_bar(bar) if bar
|
174
|
+
join.call(error) if join
|
150
175
|
end
|
151
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
152
|
-
join.call if join
|
153
176
|
end
|
154
177
|
|
155
178
|
def self.traverse_io_array(io, options = {}, &block)
|
156
179
|
callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
180
|
+
begin
|
181
|
+
error = false
|
182
|
+
if File === io and io.closed?
|
183
|
+
begin
|
184
|
+
Log.low{"Rewinding stream #{stream_name(io)}"}
|
185
|
+
io.reopen io.filename, "r"
|
186
|
+
rescue
|
187
|
+
Log.exception $!
|
188
|
+
raise "File closed and could not reopen #{stream_name(io)}"
|
189
|
+
end
|
164
190
|
end
|
165
|
-
end
|
166
191
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
192
|
+
if callback
|
193
|
+
bar.init if bar
|
194
|
+
while line = io.gets
|
195
|
+
if line[-1] != "\n"
|
196
|
+
while c = io.getc
|
197
|
+
line << c
|
198
|
+
break if c=="\n"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
begin
|
202
|
+
callback.call yield line.chomp
|
203
|
+
ensure
|
204
|
+
bar.tick if bar
|
174
205
|
end
|
175
206
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
while line = io.gets
|
185
|
-
begin
|
186
|
-
yield line.chomp
|
187
|
-
ensure
|
188
|
-
bar.tick if bar
|
207
|
+
else
|
208
|
+
bar.init if bar
|
209
|
+
while line = io.gets
|
210
|
+
begin
|
211
|
+
yield line.chomp
|
212
|
+
ensure
|
213
|
+
bar.tick if bar
|
214
|
+
end
|
189
215
|
end
|
190
216
|
end
|
217
|
+
rescue
|
218
|
+
error = true
|
219
|
+
raise $!
|
220
|
+
ensure
|
221
|
+
Log::ProgressBar.remove_bar(bar) if bar
|
222
|
+
join.call(error) if join
|
191
223
|
end
|
192
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
193
|
-
join.call if join
|
194
224
|
end
|
195
225
|
|
196
226
|
def self.traverse_io(io, options = {}, &block)
|
197
227
|
callback, bar, join = Misc.process_options options, :callback, :bar, :join
|
198
|
-
if File === io and io.closed?
|
199
|
-
begin
|
200
|
-
Log.low{"Rewinding stream #{stream_name(io)}"}
|
201
|
-
io.reopen io.filename, "r"
|
202
|
-
rescue
|
203
|
-
Log.exception $!
|
204
|
-
raise "File closed and could not reopen #{stream_name(io)}"
|
205
|
-
end
|
206
|
-
end
|
207
228
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
exception = nil
|
212
|
-
begin
|
213
|
-
TSV::Parser.traverse(io, options) do |k,v|
|
229
|
+
begin
|
230
|
+
error = false
|
231
|
+
if File === io and io.closed?
|
214
232
|
begin
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
233
|
+
Log.low{"Rewinding stream #{stream_name(io)}"}
|
234
|
+
io.reopen io.filename, "r"
|
235
|
+
rescue
|
236
|
+
Log.exception $!
|
237
|
+
raise "File closed and could not reopen #{stream_name(io)}"
|
219
238
|
end
|
220
|
-
bar.tick if bar
|
221
239
|
end
|
222
|
-
|
223
|
-
|
240
|
+
|
241
|
+
options[:monitor] = bar
|
242
|
+
if callback
|
243
|
+
bar.init if bar
|
244
|
+
exception = nil
|
245
|
+
begin
|
246
|
+
TSV::Parser.traverse(io, options) do |k,v|
|
247
|
+
begin
|
248
|
+
callback.call yield k, v
|
249
|
+
rescue Exception
|
250
|
+
exception = $!
|
251
|
+
raise $!
|
252
|
+
end
|
253
|
+
bar.tick if bar
|
254
|
+
end
|
255
|
+
ensure
|
256
|
+
raise exception if exception
|
257
|
+
end
|
258
|
+
else
|
259
|
+
TSV::Parser.traverse(io, options.merge(:monitor => bar), &block)
|
224
260
|
end
|
225
|
-
|
226
|
-
|
261
|
+
rescue
|
262
|
+
error = true
|
263
|
+
raise $!
|
264
|
+
ensure
|
265
|
+
Log::ProgressBar.remove_bar(bar) if bar
|
266
|
+
join.call(error) if join
|
227
267
|
end
|
228
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
229
|
-
join.call if join
|
230
268
|
end
|
231
269
|
|
232
270
|
def self.traverse_obj(obj, options = {}, &block)
|
@@ -261,6 +299,7 @@ module TSV
|
|
261
299
|
end
|
262
300
|
rescue Aborted
|
263
301
|
obj.abort if obj.respond_to? :abort
|
302
|
+
raise $!
|
264
303
|
rescue Exception
|
265
304
|
obj.abort if obj.respond_to? :abort
|
266
305
|
raise $!
|
@@ -380,6 +419,7 @@ module TSV
|
|
380
419
|
stream.abort if stream.respond_to? :abort
|
381
420
|
stream = obj_stream(options[:into])
|
382
421
|
stream.abort if stream.respond_to? :abort
|
422
|
+
q.join
|
383
423
|
raise "Traversal aborted"
|
384
424
|
rescue Exception
|
385
425
|
error = true
|
@@ -389,6 +429,7 @@ module TSV
|
|
389
429
|
stream.abort if stream.respond_to? :abort
|
390
430
|
stream = obj_stream(options[:into])
|
391
431
|
stream.abort if stream.respond_to? :abort
|
432
|
+
q.join
|
392
433
|
raise $!
|
393
434
|
ensure
|
394
435
|
if bar
|
data/lib/rbbt/util/cmd.rb
CHANGED
@@ -116,10 +116,16 @@ module CMD
|
|
116
116
|
in_content.join if in_content.respond_to? :join
|
117
117
|
end
|
118
118
|
rescue
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
Log.exception $!
|
120
|
+
raise $!
|
121
|
+
# begin
|
122
|
+
# Process.kill "INT", pid
|
123
|
+
# #parent.raise $!
|
124
|
+
# ensure
|
125
|
+
# raise $!
|
126
|
+
# end
|
127
|
+
#ensure
|
128
|
+
# #sin.close unless sin.closed?
|
123
129
|
end
|
124
130
|
end
|
125
131
|
else
|
@@ -135,7 +135,7 @@ class RbbtProcessQueue
|
|
135
135
|
retry
|
136
136
|
rescue Aborted
|
137
137
|
Log.low "Aborting manager thread #{Process.pid}"
|
138
|
-
raise
|
138
|
+
raise $!
|
139
139
|
rescue Exception
|
140
140
|
raise Exception
|
141
141
|
end
|
@@ -254,16 +254,19 @@ class RbbtProcessQueue
|
|
254
254
|
@callback_thread.join
|
255
255
|
error = false
|
256
256
|
rescue Aborted, Interrupt
|
257
|
+
exception = $!
|
257
258
|
Log.exception $!
|
258
|
-
self.abort
|
259
259
|
error = true
|
260
|
+
self.abort
|
260
261
|
Log.high "Process queue #{@master_pid} aborted"
|
261
262
|
retry
|
262
263
|
rescue Errno::ESRCH, Errno::ECHILD
|
263
264
|
retry if Misc.pid_exists? @master_pid
|
264
265
|
error = ! @status.success?
|
265
266
|
rescue ProcessFailed
|
267
|
+
exception = $!
|
266
268
|
rescue Exception
|
269
|
+
exception = $!
|
267
270
|
Log.exception $!
|
268
271
|
retry
|
269
272
|
ensure
|
@@ -292,6 +295,12 @@ class RbbtProcessQueue
|
|
292
295
|
ensure
|
293
296
|
self.clean
|
294
297
|
end
|
298
|
+
|
299
|
+
if exception
|
300
|
+
raise exception
|
301
|
+
else
|
302
|
+
raise "Process queue #{@master_pid} failed"
|
303
|
+
end if error
|
295
304
|
end
|
296
305
|
end
|
297
306
|
|
@@ -321,8 +330,12 @@ class RbbtProcessQueue
|
|
321
330
|
|
322
331
|
def abort
|
323
332
|
_abort
|
324
|
-
|
333
|
+
@callback_thread.raise(Aborted.new) if @callback_thread and @callback_thread.alive?
|
325
334
|
@aborted = true
|
335
|
+
begin
|
336
|
+
_join
|
337
|
+
rescue
|
338
|
+
end
|
326
339
|
end
|
327
340
|
|
328
341
|
def clean
|
@@ -117,24 +117,26 @@ module ConcurrentStream
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def join
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
120
|
+
begin
|
121
|
+
join_threads
|
122
|
+
join_pids
|
123
|
+
join_callback
|
124
|
+
close unless closed?
|
125
|
+
ensure
|
126
|
+
@joined = true
|
127
|
+
lockfile.unlock if lockfile and lockfile.locked?
|
128
|
+
end
|
129
129
|
end
|
130
130
|
|
131
131
|
def abort_threads(exception = nil)
|
132
132
|
return unless @threads and @threads.any?
|
133
|
-
|
133
|
+
name = Thread.current.inspect
|
134
|
+
name = filename if filename
|
135
|
+
Log.low "Aborting threads (#{name}) #{@threads.collect{|t| t.inspect } * ", "}"
|
134
136
|
|
135
137
|
@threads.each do |t|
|
136
138
|
next if t == Thread.current
|
137
|
-
Log.debug "Aborting thread #{t.inspect} with exception: #{exception}"
|
139
|
+
Log.debug "Aborting thread (#{name}) #{t.inspect} with exception: #{exception}"
|
138
140
|
t.raise((exception.nil? ? Aborted.new : exception))
|
139
141
|
end
|
140
142
|
|
@@ -142,14 +144,14 @@ module ConcurrentStream
|
|
142
144
|
next if t == Thread.current
|
143
145
|
if t.alive?
|
144
146
|
sleep 1
|
145
|
-
Log.low "Kill thread #{t.inspect}"
|
147
|
+
Log.low "Kill thread (#{name}) #{t.inspect}"
|
146
148
|
t.kill
|
147
149
|
end
|
148
150
|
begin
|
149
151
|
t.join unless t == Thread.current
|
150
152
|
rescue Aborted
|
151
153
|
rescue Exception
|
152
|
-
Log.debug "Thread exception: #{$!.message}"
|
154
|
+
Log.debug "Thread (#{name}) exception: #{$!.message}"
|
153
155
|
end
|
154
156
|
end
|
155
157
|
end
|
@@ -219,11 +221,15 @@ module ConcurrentStream
|
|
219
221
|
end
|
220
222
|
|
221
223
|
def raise(exception)
|
222
|
-
|
223
|
-
|
224
|
-
|
224
|
+
begin
|
225
|
+
threads.each do |thread|
|
226
|
+
thread.raise exception
|
227
|
+
end
|
225
228
|
|
226
|
-
|
229
|
+
self.abort
|
230
|
+
ensure
|
231
|
+
Kernel.raise $!
|
232
|
+
end
|
227
233
|
end
|
228
234
|
|
229
235
|
end
|
@@ -155,8 +155,6 @@ 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
|
160
158
|
if msg
|
161
159
|
Log.warn("Not Insisting after Aborted: #{$!.message} -- #{msg}")
|
162
160
|
else
|
@@ -172,10 +170,6 @@ def self.add_libdir(dir=nil)
|
|
172
170
|
Log.warn("Insisting after exception: #{$!.class} #{$!.message}")
|
173
171
|
end
|
174
172
|
|
175
|
-
Log.stack caller
|
176
|
-
Log.exception $!
|
177
|
-
|
178
|
-
|
179
173
|
if sleep and try > 0
|
180
174
|
sleep sleep
|
181
175
|
sleep = sleep_array.shift || sleep if sleep_array
|
data/lib/rbbt/util/misc/pipes.rb
CHANGED
@@ -68,7 +68,7 @@ module Misc
|
|
68
68
|
|
69
69
|
if do_fork
|
70
70
|
|
71
|
-
parent_pid = Process.pid
|
71
|
+
#parent_pid = Process.pid
|
72
72
|
pid = Process.fork {
|
73
73
|
purge_pipes(sin)
|
74
74
|
sout.close
|
@@ -79,7 +79,7 @@ module Misc
|
|
79
79
|
|
80
80
|
rescue Exception
|
81
81
|
Log.exception $!
|
82
|
-
Process.kill :INT, parent_pid
|
82
|
+
#Process.kill :INT, parent_pid
|
83
83
|
Kernel.exit! -1
|
84
84
|
end
|
85
85
|
Kernel.exit! 0
|
@@ -92,7 +92,7 @@ module Misc
|
|
92
92
|
|
93
93
|
ConcurrentStream.setup sin, :pair => sout
|
94
94
|
|
95
|
-
thread = Thread.new
|
95
|
+
thread = Thread.new do
|
96
96
|
begin
|
97
97
|
|
98
98
|
yield sin
|
@@ -104,7 +104,7 @@ module Misc
|
|
104
104
|
rescue Exception
|
105
105
|
Log.medium "Exception in open_pipe: #{$!.message}"
|
106
106
|
Log.exception $!
|
107
|
-
|
107
|
+
sin.close
|
108
108
|
raise $!
|
109
109
|
end
|
110
110
|
end
|
@@ -442,26 +442,34 @@ module Misc
|
|
442
442
|
|
443
443
|
def self.sort_stream(stream, header_hash = "#", cmd_args = "-u")
|
444
444
|
Misc.open_pipe do |sin|
|
445
|
-
|
446
|
-
stream = TSV.get_stream stream
|
445
|
+
stream = TSV.get_stream stream
|
447
446
|
|
447
|
+
line = stream.gets
|
448
|
+
while line =~ /^#{header_hash}/ do
|
449
|
+
sin.puts line
|
448
450
|
line = stream.gets
|
449
|
-
|
450
|
-
sin.puts line
|
451
|
-
line = stream.gets
|
452
|
-
end
|
451
|
+
end
|
453
452
|
|
454
|
-
|
455
|
-
|
453
|
+
line_stream = Misc.open_pipe do |line_stream_in|
|
454
|
+
line_stream_in.puts line
|
455
|
+
begin
|
456
456
|
Misc.consume_stream(stream, false, line_stream_in)
|
457
|
+
rescue
|
458
|
+
raise $!
|
457
459
|
end
|
460
|
+
end
|
458
461
|
|
459
|
-
|
462
|
+
sorted = CMD.cmd("env LC_ALL=C sort #{cmd_args || ""}", :in => line_stream, :pipe => true)
|
460
463
|
|
464
|
+
begin
|
461
465
|
Misc.consume_stream(sorted, false, sin)
|
462
466
|
rescue
|
463
|
-
|
464
|
-
|
467
|
+
begin
|
468
|
+
Log.exception $!
|
469
|
+
sorted.abort
|
470
|
+
stream.abort
|
471
|
+
ensure
|
472
|
+
raise $!
|
465
473
|
end
|
466
474
|
end
|
467
475
|
end
|
@@ -236,29 +236,41 @@ class Step
|
|
236
236
|
respawn = :always if respawn.nil?
|
237
237
|
|
238
238
|
Misc.bootstrap(list, cpus, :bar => "Bootstrapping dependencies for #{path} [#{cpus}]", :respawn => respawn) do |dep|
|
239
|
-
|
240
|
-
|
241
|
-
dep.produce
|
242
|
-
Log.warn "Error in bootstrap dependency #{dep.path}: #{dep.messages.last}" if dep.error? or dep.aborted?
|
243
|
-
|
244
|
-
rescue Aborted
|
239
|
+
begin
|
240
|
+
Signal.trap(:INT) do
|
245
241
|
dep.abort
|
246
|
-
|
247
|
-
|
242
|
+
raise Aborted
|
243
|
+
end
|
248
244
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
245
|
+
Misc.insist do
|
246
|
+
begin
|
247
|
+
dep.produce
|
248
|
+
Log.warn "Error in bootstrap dependency #{dep.path}: #{dep.messages.last}" if dep.error? or dep.aborted?
|
249
|
+
|
250
|
+
rescue Aborted
|
251
|
+
dep.abort
|
252
|
+
Log.warn "Aborted bootstrap dependency #{dep.path}: #{dep.messages.last}" if dep.error? or dep.aborted?
|
253
|
+
raise $!
|
254
|
+
|
255
|
+
rescue RbbtException
|
256
|
+
if canfail || dep.canfail?
|
257
|
+
Log.warn "Allowing failing of #{dep.path}: #{dep.messages.last}"
|
257
258
|
else
|
258
|
-
|
259
|
+
Log.warn "NOT Allowing failing of #{dep.path}: #{dep.messages.last}"
|
260
|
+
dep.exception $!
|
261
|
+
if dep.recoverable_error?
|
262
|
+
dep.abort
|
263
|
+
raise $!
|
264
|
+
else
|
265
|
+
raise StopInsist.new($!)
|
266
|
+
end
|
259
267
|
end
|
260
268
|
end
|
261
269
|
end
|
270
|
+
rescue
|
271
|
+
iif [:ABORTIN, dep]
|
272
|
+
dep.abort
|
273
|
+
raise $!
|
262
274
|
end
|
263
275
|
nil
|
264
276
|
end
|
@@ -416,15 +428,9 @@ class Step
|
|
416
428
|
next
|
417
429
|
end
|
418
430
|
|
419
|
-
|
420
|
-
next if dep.done? or dep.aborted?
|
421
|
-
rescue
|
422
|
-
end
|
431
|
+
next if dep.done? or dep.aborted?
|
423
432
|
|
424
|
-
|
425
|
-
dep.abort if dep.running?
|
426
|
-
rescue
|
427
|
-
end
|
433
|
+
dep.abort if dep.running?
|
428
434
|
end
|
429
435
|
kill_children
|
430
436
|
end
|
@@ -344,7 +344,6 @@ class Step
|
|
344
344
|
end
|
345
345
|
_clean_finished
|
346
346
|
rescue
|
347
|
-
Log.exception $!
|
348
347
|
stop_dependencies
|
349
348
|
set_info :pid, nil
|
350
349
|
FileUtils.rm pid_file if File.exist?(pid_file)
|
@@ -563,15 +562,16 @@ class Step
|
|
563
562
|
doretry = true
|
564
563
|
begin
|
565
564
|
return if done?
|
566
|
-
stop_dependencies
|
567
|
-
abort_stream
|
568
565
|
abort_pid if running?
|
566
|
+
abort_stream
|
567
|
+
stop_dependencies
|
569
568
|
rescue Aborted, Interrupt
|
570
569
|
Log.medium{"#{Log.color :red, "Aborting ABORTED RETRY"} #{Log.color :blue, path}"}
|
571
570
|
if doretry
|
572
571
|
doretry = false
|
573
572
|
retry
|
574
573
|
end
|
574
|
+
raise $!
|
575
575
|
rescue Exception
|
576
576
|
if doretry
|
577
577
|
doretry = false
|
@@ -269,4 +269,24 @@ line4
|
|
269
269
|
assert_equal text, lines.to_a * ""
|
270
270
|
end
|
271
271
|
end
|
272
|
+
|
273
|
+
def test_sort
|
274
|
+
assert_raise RbbtException do
|
275
|
+
io = Misc.open_pipe do |sin|
|
276
|
+
sin.puts "#START"
|
277
|
+
20.times do
|
278
|
+
sin.puts rand(1000).to_s
|
279
|
+
sleep 0.1
|
280
|
+
end
|
281
|
+
raise RbbtException
|
282
|
+
end
|
283
|
+
|
284
|
+
sio = Misc.sort_stream(io)
|
285
|
+
begin
|
286
|
+
Misc.consume_stream(sio, false, STDOUT)
|
287
|
+
rescue
|
288
|
+
Log.exception $!
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
272
292
|
end
|