rbbt-util 5.13.11 → 5.13.12
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 +11 -11
- data/lib/rbbt/tsv/parallel/traverse.rb +11 -12
- data/lib/rbbt/util/log/progress/report.rb +1 -0
- data/lib/rbbt/util/misc/concurrent_stream.rb +1 -1
- data/lib/rbbt/util/misc/pipes.rb +15 -12
- data/lib/rbbt/workflow/accessor.rb +30 -20
- data/lib/rbbt/workflow/step/run.rb +36 -40
- 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: c918ffd6618192626d6874815f0f289813184f28
|
4
|
+
data.tar.gz: 7b49a48b985dfc7657adc68e0eb35b7432967280
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7334ed69cca371f85944bc6737c4b9e9911fe51e825b93b3ea8aeaf231318c9a3c6dea2d2f3d60dd8772cc5382392c3ac18070b9a53d0132081d3edc2f01055e
|
7
|
+
data.tar.gz: eed1a8230a41553d1c245509d44b04856a90bb0e7bf0452f4f3e1776d1ce3a8491bd51d42c6856950cbb54da1efbb4493d09a860fc7fcc4a377654db1f14201d
|
data/lib/rbbt/persist.rb
CHANGED
@@ -134,7 +134,7 @@ module Persist
|
|
134
134
|
raise "Unknown persistence: #{ type }"
|
135
135
|
end
|
136
136
|
rescue
|
137
|
-
Log.
|
137
|
+
Log.medium "Exception loading #{ type } #{ path }: #{$!.message}"
|
138
138
|
raise $!
|
139
139
|
end
|
140
140
|
end
|
@@ -200,11 +200,11 @@ module Persist
|
|
200
200
|
save_file(path, type, file)
|
201
201
|
end
|
202
202
|
rescue Aborted
|
203
|
-
Log.
|
203
|
+
Log.medium "Persist stream thread aborted: #{ Log.color :blue, path }"
|
204
204
|
file.abort if file.respond_to? :abort
|
205
205
|
raise $!
|
206
206
|
rescue Exception
|
207
|
-
Log.
|
207
|
+
Log.medium "Persist stream thread exception: #{ Log.color :blue, path }"
|
208
208
|
file.abort if file.respond_to? :abort
|
209
209
|
parent.raise $!
|
210
210
|
raise $!
|
@@ -229,10 +229,10 @@ module Persist
|
|
229
229
|
end
|
230
230
|
Log.high "Stream pipe saved: #{path}"
|
231
231
|
rescue Aborted
|
232
|
-
Log.
|
232
|
+
Log.medium "Persist stream pipe exception: #{ Log.color :blue, path }"
|
233
233
|
stream.abort if stream.respond_to? :abort
|
234
234
|
rescue Exception
|
235
|
-
Log.
|
235
|
+
Log.medium "Persist stream pipe exception: #{ Log.color :blue, path }"
|
236
236
|
Log.exception $!
|
237
237
|
stream.abort if stream.respond_to? :abort
|
238
238
|
stream.join if stream.respond_to? :join
|
@@ -246,7 +246,7 @@ module Persist
|
|
246
246
|
sin.write block
|
247
247
|
end
|
248
248
|
rescue Aborted
|
249
|
-
Log.
|
249
|
+
Log.medium "Tee stream thread aborted"
|
250
250
|
sout.abort if sout.respond_to? :abort
|
251
251
|
sin.abort if sin.respond_to? :abort
|
252
252
|
rescue Exception
|
@@ -291,14 +291,14 @@ module Persist
|
|
291
291
|
begin
|
292
292
|
lockfile.unlock if File.exists? lockfile.path and lockfile.locked?
|
293
293
|
rescue
|
294
|
-
Log.
|
294
|
+
Log.medium "Lockfile exception: " << $!.message
|
295
295
|
end
|
296
296
|
end
|
297
297
|
res.abort_callback = Proc.new do
|
298
298
|
begin
|
299
299
|
lockfile.unlock if File.exists? lockfile.path and lockfile.locked?
|
300
300
|
rescue
|
301
|
-
Log.
|
301
|
+
Log.medium "Lockfile exception: " << $!.message
|
302
302
|
end
|
303
303
|
end
|
304
304
|
raise KeepLocked.new res
|
@@ -310,7 +310,7 @@ module Persist
|
|
310
310
|
stream.callback
|
311
311
|
lockfile.unlock if File.exists? lockfile.path and lockfile.locked?
|
312
312
|
rescue
|
313
|
-
Log.
|
313
|
+
Log.medium "Lockfile exception: " << $!.message
|
314
314
|
end
|
315
315
|
end
|
316
316
|
res.abort_callback = Proc.new do
|
@@ -318,7 +318,7 @@ module Persist
|
|
318
318
|
stream.abort
|
319
319
|
lockfile.unlock if File.exists? lockfile.path and lockfile.locked?
|
320
320
|
rescue
|
321
|
-
Log.
|
321
|
+
Log.medium "Lockfile exception: " << $!.message
|
322
322
|
end
|
323
323
|
end
|
324
324
|
raise KeepLocked.new res
|
@@ -385,7 +385,7 @@ module Persist
|
|
385
385
|
end
|
386
386
|
|
387
387
|
rescue
|
388
|
-
Log.
|
388
|
+
Log.medium "Error in persist: #{path}#{Open.exists?(path) ? Log.color(:red, " Erasing") : ""}"
|
389
389
|
FileUtils.rm path if Open.exists? path
|
390
390
|
raise $!
|
391
391
|
end
|
@@ -235,28 +235,28 @@ module TSV
|
|
235
235
|
raise "Unknown object for traversal: #{Misc.fingerprint obj }"
|
236
236
|
end
|
237
237
|
rescue IOError
|
238
|
-
Log.
|
238
|
+
Log.medium "IOError traversing #{stream_name(obj)}: #{$!.message}"
|
239
239
|
stream = obj_stream(obj)
|
240
240
|
stream.abort if stream and stream.respond_to? :abort
|
241
241
|
stream = obj_stream(options[:into])
|
242
242
|
stream.abort if stream.respond_to? :abort
|
243
243
|
raise $!
|
244
244
|
rescue Errno::EPIPE
|
245
|
-
Log.
|
245
|
+
Log.medium "Pipe closed while traversing #{stream_name(obj)}: #{$!.message}"
|
246
246
|
stream = obj_stream(obj)
|
247
247
|
stream.abort if stream and stream.respond_to? :abort
|
248
248
|
stream = obj_stream(options[:into])
|
249
249
|
stream.abort if stream.respond_to? :abort
|
250
250
|
raise $!
|
251
251
|
rescue Aborted
|
252
|
-
Log.
|
252
|
+
Log.medium "Aborted traversing #{stream_name(obj)}"
|
253
253
|
stream = obj_stream(obj)
|
254
254
|
stream.abort if stream and stream.respond_to? :abort
|
255
255
|
stream = obj_stream(options[:into])
|
256
256
|
stream.abort if stream.respond_to? :abort
|
257
|
-
Log.
|
257
|
+
Log.medium "Aborted traversing 2 #{stream_name(obj)}"
|
258
258
|
rescue Exception
|
259
|
-
Log.
|
259
|
+
Log.medium "Exception traversing #{stream_name(obj)}"
|
260
260
|
stream = obj_stream(obj)
|
261
261
|
stream.abort if stream and stream.respond_to? :abort
|
262
262
|
stream = obj_stream(options[:into])
|
@@ -304,7 +304,7 @@ module TSV
|
|
304
304
|
q.process *p
|
305
305
|
end
|
306
306
|
rescue Aborted, Errno::EPIPE
|
307
|
-
Log.
|
307
|
+
Log.medium "Aborted"
|
308
308
|
rescue Exception
|
309
309
|
Log.exception $!
|
310
310
|
raise $!
|
@@ -312,7 +312,7 @@ module TSV
|
|
312
312
|
q.join
|
313
313
|
end
|
314
314
|
rescue Interrupt, Aborted
|
315
|
-
Log.
|
315
|
+
Log.medium "Aborted traversal in CPUs for #{stream_name(obj) || Misc.fingerprint(obj)}: #{$!.backtrace*","}"
|
316
316
|
q.abort
|
317
317
|
stream = obj_stream(obj)
|
318
318
|
stream.abort if stream.respond_to? :abort
|
@@ -320,7 +320,7 @@ module TSV
|
|
320
320
|
stream.abort if stream.respond_to? :abort
|
321
321
|
raise "Traversal aborted"
|
322
322
|
rescue Exception
|
323
|
-
Log.
|
323
|
+
Log.medium "Exception during traversal in CPUs for #{stream_name(obj) || Misc.fingerprint(obj)}: #{$!.message}"
|
324
324
|
stream = obj_stream(obj)
|
325
325
|
stream.abort if stream.respond_to? :abort
|
326
326
|
stream = obj_stream(options[:into])
|
@@ -356,7 +356,7 @@ module TSV
|
|
356
356
|
end
|
357
357
|
true
|
358
358
|
rescue Aborted, Interrupt
|
359
|
-
Log.
|
359
|
+
Log.medium "Aborted storing into #{Misc.fingerprint store}: #{$!.message}"
|
360
360
|
stream = obj_stream(store)
|
361
361
|
stream.abort if stream.respond_to? :abort
|
362
362
|
rescue Exception
|
@@ -484,14 +484,13 @@ module TSV
|
|
484
484
|
begin
|
485
485
|
store_into into, e
|
486
486
|
rescue Aborted
|
487
|
-
Log.
|
487
|
+
Log.medium "Aborted callback #{stream_name(obj)} #{Log.color :green, "->"} #{stream_name(options[:into])}"
|
488
488
|
stream = nil
|
489
489
|
stream = get_stream obj
|
490
490
|
stream.abort if stream.respond_to? :abort
|
491
491
|
raise $!
|
492
492
|
rescue Exception
|
493
|
-
Log.
|
494
|
-
Log.exception $!
|
493
|
+
Log.medium "Exception callback #{stream_name(obj)} #{Log.color :green, "->"} #{stream_name(options[:into])}"
|
495
494
|
stream = nil
|
496
495
|
stream = get_stream obj
|
497
496
|
stream.abort if stream.respond_to? :abort
|
@@ -103,7 +103,7 @@ module ConcurrentStream
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def abort
|
106
|
-
Log.
|
106
|
+
Log.medium "Aborting stream #{Misc.fingerprint self} -- #{@abort_callback} [#{@aborted}]"
|
107
107
|
return if @aborted
|
108
108
|
@aborted = true
|
109
109
|
begin
|
data/lib/rbbt/util/misc/pipes.rb
CHANGED
@@ -64,8 +64,11 @@ module Misc
|
|
64
64
|
begin
|
65
65
|
yield sin
|
66
66
|
sin.close if close and not sin.closed?
|
67
|
+
rescue Aborted
|
68
|
+
Log.medium "Aborted open_pipe: #{$!.message}"
|
67
69
|
rescue Exception
|
68
|
-
Log.
|
70
|
+
Log.medium "Exception in open_pipe: #{$!.message}"
|
71
|
+
parent.raise $!
|
69
72
|
raise $!
|
70
73
|
end
|
71
74
|
end
|
@@ -86,14 +89,14 @@ module Misc
|
|
86
89
|
begin
|
87
90
|
stream_in1.write block;
|
88
91
|
rescue IOError
|
89
|
-
Log.
|
92
|
+
Log.medium("Tee stream 1 #{Misc.fingerprint stream} IOError: #{$!.message}");
|
90
93
|
skip1 = true
|
91
94
|
end unless skip1
|
92
95
|
|
93
96
|
begin
|
94
97
|
stream_in2.write block
|
95
98
|
rescue IOError
|
96
|
-
Log.
|
99
|
+
Log.medium("Tee stream 2 #{Misc.fingerprint stream} IOError: #{$!.message}");
|
97
100
|
skip2 = true
|
98
101
|
end unless skip2
|
99
102
|
end
|
@@ -101,17 +104,17 @@ module Misc
|
|
101
104
|
stream_in2.close unless stream_in2.closed?
|
102
105
|
stream.join if stream.respond_to? :join
|
103
106
|
rescue Aborted, Interrupt
|
104
|
-
Log.
|
107
|
+
Log.medium "Tee aborting #{Misc.fingerprint stream}"
|
105
108
|
stream.abort if stream.respond_to? :abort
|
106
109
|
stream_out1.abort if stream_out1.respond_to? :abort
|
107
110
|
stream_out2.abort if stream_out2.respond_to? :abort
|
108
|
-
Log.
|
111
|
+
Log.medium "tee_stream_thread aborted: #{$!.message}"
|
109
112
|
rescue Exception
|
110
113
|
stream.abort if stream.respond_to? :abort
|
111
114
|
stream_out1.abort if stream_out1.respond_to? :abort
|
112
115
|
stream_out2.abort if stream_out2.respond_to? :abort
|
113
116
|
stream.join
|
114
|
-
Log.
|
117
|
+
Log.medium "Exception in tee_stream_thread: #{$!.message}"
|
115
118
|
raise $!
|
116
119
|
end
|
117
120
|
end
|
@@ -153,21 +156,21 @@ module Misc
|
|
153
156
|
return
|
154
157
|
end
|
155
158
|
|
156
|
-
Log.medium "Consuming stream #{Misc.fingerprint io}"
|
157
159
|
if in_thread
|
158
160
|
Thread.new do
|
159
161
|
consume_stream(io, false)
|
160
162
|
end
|
161
163
|
else
|
164
|
+
Log.medium "Consuming stream #{Misc.fingerprint io}"
|
162
165
|
begin
|
163
166
|
while block = io.read(2048)
|
164
167
|
end
|
165
168
|
io.join if io.respond_to? :join
|
166
169
|
rescue Aborted
|
167
|
-
Log.
|
170
|
+
Log.medium "Consume stream aborted #{Misc.fingerprint io}"
|
168
171
|
io.abort if io.respond_to? :abort
|
169
172
|
rescue Exception
|
170
|
-
Log.
|
173
|
+
Log.medium "Exception consuming stream: #{Misc.fingerprint io}: #{$!.message}"
|
171
174
|
io.abort if io.respond_to? :abort
|
172
175
|
io.join
|
173
176
|
raise $!
|
@@ -219,11 +222,11 @@ module Misc
|
|
219
222
|
|
220
223
|
Open.mv tmp_path, path
|
221
224
|
rescue Aborted
|
222
|
-
Log.
|
225
|
+
Log.medium "Aborted sensiblewrite -- #{ Log.reset << Log.color(:blue, path) }"
|
223
226
|
content.abort if content.respond_to? :abort
|
224
227
|
Open.rm path if File.exists? path
|
225
228
|
rescue Exception
|
226
|
-
Log.
|
229
|
+
Log.medium "Exception in sensiblewrite: #{$!.message} -- #{ Log.color :blue, path }"
|
227
230
|
content.abort if content.respond_to? :abort
|
228
231
|
Open.rm path if File.exists? path
|
229
232
|
raise $!
|
@@ -400,7 +403,7 @@ module Misc
|
|
400
403
|
save.abort if save.respond_to? :abort
|
401
404
|
stream.abort if stream.respond_to? :abort
|
402
405
|
stream.join
|
403
|
-
Log.
|
406
|
+
Log.medium "Exception in save_stream: #{$!.message}"
|
404
407
|
raise $!
|
405
408
|
end
|
406
409
|
end
|
@@ -119,25 +119,32 @@ class Step
|
|
119
119
|
set_info(:messages, (messages || []) << message)
|
120
120
|
end
|
121
121
|
|
122
|
+
def self.status_color(status)
|
123
|
+
status = status.split(">").last
|
124
|
+
case status
|
125
|
+
when "starting"
|
126
|
+
:yellow
|
127
|
+
when "error", "aborted"
|
128
|
+
:red
|
129
|
+
when "done"
|
130
|
+
:green
|
131
|
+
else
|
132
|
+
:cyan
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
122
136
|
def self.log_block(staus, message, path, &block)
|
123
137
|
start = Time.now
|
124
138
|
status = status.to_s
|
125
|
-
status_color =
|
126
|
-
|
127
|
-
:yellow
|
128
|
-
when "error"
|
129
|
-
:red
|
130
|
-
when "done"
|
131
|
-
:green
|
132
|
-
else
|
133
|
-
:cyan
|
134
|
-
end
|
139
|
+
status_color = self.status_color status
|
140
|
+
|
135
141
|
Log.info do
|
136
142
|
now = Time.now
|
137
143
|
str = Log.color :reset
|
138
144
|
str << "#{ Log.color status_color, status}"
|
139
145
|
str << ": #{ message }" if message
|
140
146
|
str << " -- #{Log.color :blue, path.to_s}" if path
|
147
|
+
str << " #{Log.color :yellow, Process.pid}"
|
141
148
|
str
|
142
149
|
end
|
143
150
|
res = yield
|
@@ -146,6 +153,7 @@ class Step
|
|
146
153
|
now = Time.now
|
147
154
|
str = "#{ Log.color :cyan, status.to_s } +#{Log.color :green, "%.1g" % (eend - start)}"
|
148
155
|
str << " -- #{Log.color :blue, path.to_s}" if path
|
156
|
+
str << " #{Log.color :yellow, Process.pid}"
|
149
157
|
str
|
150
158
|
end
|
151
159
|
res
|
@@ -155,21 +163,13 @@ class Step
|
|
155
163
|
Log.info do
|
156
164
|
|
157
165
|
status = status.to_s
|
158
|
-
status_color =
|
159
|
-
when "starting"
|
160
|
-
:yellow
|
161
|
-
when "error"
|
162
|
-
:red
|
163
|
-
when "done"
|
164
|
-
:green
|
165
|
-
else
|
166
|
-
:cyan
|
167
|
-
end
|
166
|
+
status_color = self.status_color status
|
168
167
|
|
169
168
|
str = Log.color :reset
|
170
169
|
str << "#{ Log.color status_color, status}"
|
171
170
|
str << ": #{ message }" if message
|
172
171
|
str << " -- #{Log.color :blue, path.to_s}" if path
|
172
|
+
str << " #{Log.color :yellow, Process.pid}"
|
173
173
|
str
|
174
174
|
end
|
175
175
|
end
|
@@ -206,6 +206,16 @@ class Step
|
|
206
206
|
Step.log(status, message, path, &block)
|
207
207
|
end
|
208
208
|
|
209
|
+
def exception(ex, msg = nil)
|
210
|
+
self._abort
|
211
|
+
set_info :backtrace, ex.backtrace
|
212
|
+
if msg.nil?
|
213
|
+
log :error, "Exception -- #{ex.message}"
|
214
|
+
else
|
215
|
+
log :error, "#{msg} -- #{ex.message}"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
209
219
|
def started?
|
210
220
|
Open.exists? info_file or Open.exists? path
|
211
221
|
end
|
@@ -19,10 +19,13 @@ class Step
|
|
19
19
|
Log.medium "Reopening file #{ Misc.fingerprint(current) }"
|
20
20
|
Open.open(current.filename)
|
21
21
|
else
|
22
|
-
Log.medium "Duplicating file #{ Misc.fingerprint(current) }"
|
23
|
-
|
24
|
-
new
|
25
|
-
new
|
22
|
+
Log.medium "Duplicating file #{ Misc.fingerprint(current) } #{current.inspect}"
|
23
|
+
Misc.dup_stream(current)
|
24
|
+
#STREAM_CACHE[stream] = new
|
25
|
+
#new
|
26
|
+
#new = current.dup
|
27
|
+
#new.rewind
|
28
|
+
#new
|
26
29
|
end
|
27
30
|
|
28
31
|
else
|
@@ -149,22 +152,13 @@ class Step
|
|
149
152
|
dependency.run(true)
|
150
153
|
end
|
151
154
|
rescue Aborted
|
152
|
-
|
153
|
-
set_info :backtrace, backtrace
|
154
|
-
log(:error, "Aborted dependency #{Log.color :yellow, dependency.task.name.to_s}")
|
155
|
-
self.abort
|
155
|
+
Log.error "Aborted dep. #{Log.color :red, dependency.task.name.to_s}"
|
156
156
|
raise $!
|
157
157
|
rescue Interrupt
|
158
|
-
|
159
|
-
set_info :backtrace, backtrace
|
160
|
-
self.abort
|
161
|
-
log(:error, "Interrupted dependency #{Log.color :yellow, dependency.task.name.to_s}")
|
158
|
+
Log.error "Interrupted while in dep. #{Log.color :red, dependency.task.name.to_s}"
|
162
159
|
raise $!
|
163
160
|
rescue Exception
|
164
|
-
|
165
|
-
set_info :backtrace, backtrace
|
166
|
-
log(:error, "Exception processing dependency #{Log.color :yellow, dependency.task.name.to_s} -- #{$!.class}: #{$!.message}")
|
167
|
-
self.abort
|
161
|
+
Log.error "Exception in dep. #{ Log.color :red, dependency.task.name.to_s }"
|
168
162
|
raise $!
|
169
163
|
end
|
170
164
|
end
|
@@ -196,8 +190,7 @@ class Step
|
|
196
190
|
dup_inputs
|
197
191
|
begin
|
198
192
|
run_dependencies
|
199
|
-
rescue
|
200
|
-
log(:error, "Error procesing dependencies")
|
193
|
+
rescue Exception
|
201
194
|
stop_dependencies
|
202
195
|
raise $!
|
203
196
|
end
|
@@ -206,7 +199,7 @@ class Step
|
|
206
199
|
set_info :inputs, Misc.remove_long_items(Misc.zip2hash(task.inputs, @inputs)) unless task.inputs.nil?
|
207
200
|
|
208
201
|
set_info :started, (start_time = Time.now)
|
209
|
-
log :started, "#{Log.color :green, "Starting task"} #{Log.color :yellow, task.name.to_s || ""}
|
202
|
+
log :started, "#{Log.color :green, "Starting task"} #{Log.color :yellow, task.name.to_s || ""}"
|
210
203
|
|
211
204
|
begin
|
212
205
|
result = _exec
|
@@ -234,12 +227,14 @@ class Step
|
|
234
227
|
case result
|
235
228
|
when IO
|
236
229
|
|
237
|
-
log :streaming, "#{Log.color :magenta, "Streaming IO"} #{Log.color :yellow, task.name.to_s || ""}
|
230
|
+
log :streaming, "#{Log.color :magenta, "Streaming IO"} #{Log.color :yellow, task.name.to_s || ""}"
|
238
231
|
ConcurrentStream.setup result do
|
239
232
|
begin
|
240
|
-
|
241
|
-
|
242
|
-
|
233
|
+
if status != :done
|
234
|
+
set_info :done, (done_time = Time.now)
|
235
|
+
set_info :time_elapsed, (time_elapsed = done_time - start_time)
|
236
|
+
log :done, "#{Log.color :red, "Completed"} #{Log.color :yellow, task.name.to_s || ""} in #{time_elapsed.to_i} sec."
|
237
|
+
end
|
243
238
|
rescue
|
244
239
|
Log.exception $!
|
245
240
|
ensure
|
@@ -248,7 +243,7 @@ class Step
|
|
248
243
|
end
|
249
244
|
result.abort_callback = Proc.new do
|
250
245
|
begin
|
251
|
-
log :
|
246
|
+
log :aborted, "#{Log.color :red, "Aborted"} #{Log.color :yellow, task.name.to_s || ""}" if status == :streaming
|
252
247
|
rescue
|
253
248
|
Log.exception $!
|
254
249
|
ensure
|
@@ -256,12 +251,14 @@ class Step
|
|
256
251
|
end
|
257
252
|
end
|
258
253
|
when TSV::Dumper
|
259
|
-
log :streaming, "#{Log.color :magenta, "Streaming TSV::Dumper"} #{Log.color :yellow, task.name.to_s || ""}
|
254
|
+
log :streaming, "#{Log.color :magenta, "Streaming TSV::Dumper"} #{Log.color :yellow, task.name.to_s || ""}"
|
260
255
|
ConcurrentStream.setup result.stream do
|
261
256
|
begin
|
262
|
-
|
263
|
-
|
264
|
-
|
257
|
+
if status != :done
|
258
|
+
set_info :done, (done_time = Time.now)
|
259
|
+
set_info :time_elapsed, (time_elapsed = done_time - start_time)
|
260
|
+
log :done, "#{Log.color :red, "Completed"} #{Log.color :yellow, task.name.to_s || ""} in #{time_elapsed.to_i} sec."
|
261
|
+
end
|
265
262
|
rescue
|
266
263
|
Log.exception $!
|
267
264
|
ensure
|
@@ -270,7 +267,7 @@ class Step
|
|
270
267
|
end
|
271
268
|
result.stream.abort_callback = Proc.new do
|
272
269
|
begin
|
273
|
-
log :
|
270
|
+
log :aborted, "#{Log.color :red, "Aborted"} #{Log.color :yellow, task.name.to_s || ""}" if status == :streaming
|
274
271
|
rescue Exception
|
275
272
|
Log.exception $!
|
276
273
|
end
|
@@ -278,7 +275,7 @@ class Step
|
|
278
275
|
else
|
279
276
|
set_info :done, (done_time = Time.now)
|
280
277
|
set_info :time_elapsed, (time_elapsed = done_time - start_time)
|
281
|
-
log :done, "#{Log.color :red, "Completed
|
278
|
+
log :done, "#{Log.color :red, "Completed"} #{Log.color :yellow, task.name.to_s || ""} in #{time_elapsed.to_i} sec."
|
282
279
|
end
|
283
280
|
|
284
281
|
result
|
@@ -292,7 +289,7 @@ class Step
|
|
292
289
|
end
|
293
290
|
end
|
294
291
|
rescue Exception
|
295
|
-
|
292
|
+
exception $!
|
296
293
|
raise $!
|
297
294
|
end
|
298
295
|
end
|
@@ -390,7 +387,7 @@ class Step
|
|
390
387
|
end
|
391
388
|
end
|
392
389
|
|
393
|
-
def
|
390
|
+
def _abort
|
394
391
|
return if @aborted
|
395
392
|
@aborted = true
|
396
393
|
return if done?
|
@@ -406,30 +403,29 @@ class Step
|
|
406
403
|
retry
|
407
404
|
ensure
|
408
405
|
if Open.exists? path
|
409
|
-
Log.warn "Aborted job had finished. Removing result"
|
406
|
+
Log.warn "Aborted job had finished. Removing result -- #{ path }"
|
410
407
|
begin
|
411
408
|
Open.rm path
|
412
409
|
rescue Exception
|
413
410
|
Log.warn "Exception removing result of aborted job: #{$!.message}"
|
414
411
|
end
|
415
412
|
end
|
416
|
-
|
417
|
-
begin
|
418
|
-
log(:aborted, "Job aborted")
|
419
|
-
rescue Exception
|
420
|
-
Log.exception $!
|
421
|
-
end
|
422
413
|
end
|
423
414
|
Log.medium{"#{Log.color :red, "Aborted"} #{Log.color :blue, path}"}
|
424
415
|
end
|
425
416
|
|
417
|
+
def abort
|
418
|
+
_abort
|
419
|
+
log(:aborted, "Job aborted") unless aborted? or error?
|
420
|
+
end
|
421
|
+
|
426
422
|
def join_stream
|
427
423
|
stream = get_stream if @result
|
428
424
|
if stream
|
429
425
|
begin
|
430
426
|
Misc.consume_stream stream
|
431
427
|
rescue Exception
|
432
|
-
self.
|
428
|
+
self._abort
|
433
429
|
raise $!
|
434
430
|
end
|
435
431
|
end
|