rbbt-util 5.17.28 → 5.17.29
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 +12 -3
- data/lib/rbbt/util/misc/concurrent_stream.rb +9 -2
- data/lib/rbbt/util/misc/lock.rb +10 -3
- data/lib/rbbt/util/misc/pipes.rb +52 -44
- data/lib/rbbt/workflow/accessor.rb +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: b1776d45c03dd038001efb190c498041002029e2
|
4
|
+
data.tar.gz: 460b271b717c540d6ea68799fc0194e5ab026a16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f2da706209429c3fb3901fae18c0e133bdd97d43700d23f12aa3c5d86d81233db986b08ae3187a387788eb06d847438697a259a7dbb2901a29b12cd11220245
|
7
|
+
data.tar.gz: 1cb89ce33d0f81232729dc2eb1ee8ea7561d6494eb5ba2a33ed161c8eca0e9b75865ee2cf9142e9309cd6d6076d3e51c3ec867469194c7d734c05b8b3217e88c
|
data/lib/rbbt/persist.rb
CHANGED
@@ -194,6 +194,7 @@ module Persist
|
|
194
194
|
|
195
195
|
saver_thread = Thread.new(Thread.current) do |parent|
|
196
196
|
begin
|
197
|
+
file.threads = []
|
197
198
|
Thread.current["name"] = "file saver: " + path
|
198
199
|
save_file(path, type, file, lockfile)
|
199
200
|
rescue Aborted
|
@@ -205,12 +206,15 @@ module Persist
|
|
205
206
|
file.abort if file.respond_to? :abort
|
206
207
|
parent.raise $!
|
207
208
|
raise $!
|
209
|
+
rescue Exception
|
210
|
+
Log.exception $!
|
211
|
+
raise $!
|
208
212
|
end
|
209
213
|
end
|
210
214
|
ConcurrentStream.setup(out, :threads => saver_thread, :filename => path)
|
211
215
|
out.callback = callback
|
212
216
|
out.abort_callback = abort_callback
|
213
|
-
out.lockfile = stream.lockfile if stream.respond_to? :lockfile
|
217
|
+
out.lockfile = stream.lockfile if stream.respond_to? :lockfile and stream.lockfile
|
214
218
|
out
|
215
219
|
end
|
216
220
|
|
@@ -225,8 +229,12 @@ module Persist
|
|
225
229
|
|
226
230
|
if stream
|
227
231
|
if persist_options[:no_load] == :stream
|
228
|
-
|
229
|
-
|
232
|
+
callback = stream.respond_to?(:callback)? stream.callback : nil
|
233
|
+
abort_callback = stream.respond_to?(:abort_callback)? stream.abort_callback : nil
|
234
|
+
|
235
|
+
res = tee_stream(stream, path, type, callback, abort_callback, lockfile)
|
236
|
+
|
237
|
+
res.lockfile = lockfile
|
230
238
|
|
231
239
|
raise KeepLocked.new res
|
232
240
|
else
|
@@ -278,6 +286,7 @@ module Persist
|
|
278
286
|
Misc.insist do
|
279
287
|
if is_persisted?(path, persist_options)
|
280
288
|
Log.low "Persist up-to-date (suddenly): #{ path } - #{Misc.fingerprint persist_options}"
|
289
|
+
lockfile.unlock if lockfile.locked?
|
281
290
|
return path if persist_options[:no_load]
|
282
291
|
return load_file(path, type)
|
283
292
|
end
|
@@ -50,10 +50,17 @@ module ConcurrentStream
|
|
50
50
|
def join_threads
|
51
51
|
if @threads and @threads.any?
|
52
52
|
@threads.each do |t|
|
53
|
-
|
53
|
+
next if t == Thread.current
|
54
|
+
begin
|
55
|
+
#t.join if t.status == 'run'
|
56
|
+
t.join unless FalseClass === t.status
|
57
|
+
rescue Exception
|
58
|
+
Log.warn "Exception joining thread in ConcurrenStream: #{filename}"
|
59
|
+
raise $!
|
60
|
+
end
|
54
61
|
end
|
55
|
-
@threads = []
|
56
62
|
end
|
63
|
+
@threads = []
|
57
64
|
end
|
58
65
|
|
59
66
|
def join_pids
|
data/lib/rbbt/util/misc/lock.rb
CHANGED
@@ -20,10 +20,10 @@ module Misc
|
|
20
20
|
LOCK_MUTEX = Mutex.new
|
21
21
|
def self.lock(file, unlock = true, options = {})
|
22
22
|
unlock, options = true, unlock if Hash === unlock
|
23
|
-
return yield if file.nil?
|
23
|
+
return yield if file.nil? and not Lockfile === options[:lock]
|
24
|
+
|
24
25
|
FileUtils.mkdir_p File.dirname(File.expand_path(file)) unless File.exists? File.dirname(File.expand_path(file))
|
25
26
|
|
26
|
-
res = nil
|
27
27
|
|
28
28
|
case options[:lock]
|
29
29
|
when Lockfile
|
@@ -42,6 +42,8 @@ module Misc
|
|
42
42
|
lockfile.lock
|
43
43
|
end
|
44
44
|
|
45
|
+
res = nil
|
46
|
+
|
45
47
|
begin
|
46
48
|
res = yield lockfile
|
47
49
|
rescue KeepLocked
|
@@ -50,8 +52,13 @@ module Misc
|
|
50
52
|
ensure
|
51
53
|
if unlock
|
52
54
|
begin
|
53
|
-
|
55
|
+
if lockfile.locked?
|
56
|
+
lockfile.unlock
|
57
|
+
else
|
58
|
+
end
|
54
59
|
rescue Exception
|
60
|
+
Log.warn "Exception unlocking: #{lockfile.path}"
|
61
|
+
Log.exception $!
|
55
62
|
end
|
56
63
|
end
|
57
64
|
end
|
data/lib/rbbt/util/misc/pipes.rb
CHANGED
@@ -230,49 +230,57 @@ module Misc
|
|
230
230
|
Misc.lock tmp_path_lock, lock_options do
|
231
231
|
|
232
232
|
if Open.exists? path and not force
|
233
|
+
Log.warn "Path exists in sensiblewrite, not forcing update: #{ path }"
|
233
234
|
Misc.consume_stream content
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
f.write block
|
235
|
+
else
|
236
|
+
FileUtils.mkdir_p File.dirname(tmp_path) unless File.directory? File.dirname(tmp_path)
|
237
|
+
FileUtils.rm_f tmp_path if File.exists? tmp_path
|
238
|
+
begin
|
239
|
+
case
|
240
|
+
when block_given?
|
241
|
+
File.open(tmp_path, 'wb', &block)
|
242
|
+
when String === content
|
243
|
+
File.open(tmp_path, 'wb') do |f| f.write content end
|
244
|
+
when (IO === content or StringIO === content or File === content)
|
245
|
+
|
246
|
+
Open.write(tmp_path) do |f|
|
247
|
+
f.sync = true
|
248
|
+
while block = content.read(2048)
|
249
|
+
f.write block
|
250
|
+
end
|
251
251
|
end
|
252
|
+
else
|
253
|
+
File.open(tmp_path, 'wb') do |f| end
|
252
254
|
end
|
253
|
-
else
|
254
|
-
File.open(tmp_path, 'wb') do |f| end
|
255
|
-
end
|
256
255
|
|
257
|
-
|
258
|
-
|
256
|
+
begin
|
257
|
+
Open.mv tmp_path, path, lock_options
|
258
|
+
rescue Exception
|
259
|
+
raise $! unless File.exists? path
|
260
|
+
end
|
261
|
+
|
262
|
+
content.join if content.respond_to? :join and not content.joined?
|
263
|
+
|
264
|
+
if Lockfile === lock_options[:lock] and lock_options[:lock].locked?
|
265
|
+
lock_options[:lock].unlock
|
266
|
+
end
|
267
|
+
FileUtils.touch path if File.exists? path
|
268
|
+
rescue Aborted
|
269
|
+
Log.medium "Aborted sensiblewrite -- #{ Log.reset << Log.color(:blue, path) }"
|
270
|
+
content.abort if content.respond_to? :abort
|
271
|
+
Open.rm path if File.exists? path
|
272
|
+
rescue Exception
|
273
|
+
Log.medium "Exception in sensiblewrite: #{$!.message} -- #{ Log.color :blue, path }"
|
274
|
+
Log.exception $!
|
275
|
+
content.abort if content.respond_to? :abort
|
276
|
+
Open.rm path if File.exists? path
|
277
|
+
raise $!
|
259
278
|
rescue
|
260
|
-
|
279
|
+
Log.exception $!
|
280
|
+
raise $!
|
281
|
+
ensure
|
282
|
+
FileUtils.rm_f tmp_path if File.exists? tmp_path
|
261
283
|
end
|
262
|
-
content.join if content.respond_to? :join
|
263
|
-
FileUtils.touch path if File.exists? path
|
264
|
-
rescue Aborted
|
265
|
-
Log.medium "Aborted sensiblewrite -- #{ Log.reset << Log.color(:blue, path) }"
|
266
|
-
content.abort if content.respond_to? :abort
|
267
|
-
Open.rm path if File.exists? path
|
268
|
-
rescue Exception
|
269
|
-
Log.medium "Exception in sensiblewrite: #{$!.message} -- #{ Log.color :blue, path }"
|
270
|
-
Log.exception $!
|
271
|
-
content.abort if content.respond_to? :abort
|
272
|
-
Open.rm path if File.exists? path
|
273
|
-
raise $!
|
274
|
-
ensure
|
275
|
-
FileUtils.rm_f tmp_path if File.exists? tmp_path
|
276
284
|
end
|
277
285
|
end
|
278
286
|
end
|
@@ -446,6 +454,8 @@ module Misc
|
|
446
454
|
|
447
455
|
def self.save_stream(file, stream)
|
448
456
|
out, save = Misc.tee_stream stream
|
457
|
+
out.filename = file
|
458
|
+
save.filename = file
|
449
459
|
|
450
460
|
Thread.new(Thread.current) do |parent|
|
451
461
|
begin
|
@@ -466,13 +476,11 @@ module Misc
|
|
466
476
|
Misc.open_pipe do |sin|
|
467
477
|
continue = true
|
468
478
|
while continue
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
line1 = nil
|
475
|
-
line2 = nil
|
479
|
+
lines = streams.collect{|stream| stream.eof? ? nil : stream.gets }.compact
|
480
|
+
lines.each do |line|
|
481
|
+
sin.puts line
|
482
|
+
end
|
483
|
+
continue = false if lines.empty?
|
476
484
|
end
|
477
485
|
streams.each do |stream|
|
478
486
|
stream.join if stream.respond_to? :join
|
@@ -121,7 +121,7 @@ class Step
|
|
121
121
|
return nil if @exec or info_file.nil?
|
122
122
|
value = Annotated.purge value if defined? Annotated
|
123
123
|
Open.lock(info_file, :lock => info_lock) do
|
124
|
-
i = info(false)
|
124
|
+
i = info(false).dup
|
125
125
|
i[key] = value
|
126
126
|
@info_cache = i
|
127
127
|
Misc.sensiblewrite(info_file, INFO_SERIALIAZER.dump(i), :force => true, :lock => false)
|
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.17.
|
4
|
+
version: 5.17.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|