rbbt-util 5.13.30 → 5.13.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/monitor.rb +3 -1
- data/lib/rbbt/persist.rb +68 -34
- data/lib/rbbt/tsv.rb +1 -1
- data/lib/rbbt/util/concurrency/processes.rb +10 -2
- data/lib/rbbt/util/concurrency/processes/worker.rb +5 -2
- data/lib/rbbt/util/misc/development.rb +6 -0
- data/lib/rbbt/util/misc/lock.rb +9 -29
- data/lib/rbbt/util/misc/pipes.rb +1 -0
- data/lib/rbbt/util/open.rb +2 -1
- data/lib/rbbt/workflow/accessor.rb +6 -2
- data/lib/rbbt/workflow/step.rb +1 -1
- data/lib/rbbt/workflow/step/run.rb +2 -2
- data/share/rbbt_commands/system/clean +5 -5
- data/share/rbbt_commands/system/deleted_files +49 -0
- data/share/rbbt_commands/system/status +9 -9
- data/test/rbbt/util/misc/test_lock.rb +63 -16
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22e6c0ab1705d1790142288b6bc9943665830554
|
4
|
+
data.tar.gz: 7873db2daa7dafc6ee9b8e1ba9ac12191c8c5d8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07dee96dd2fabee74fbf1ae2852a657f16f30f16c818c092ebd352a6769b080155881a255a48098ebcf749efa95abb13cd9e9da82cecdbdec1a0e415be0c1940
|
7
|
+
data.tar.gz: 547fd0998e00974bc5ecd8bc3ba1b8a98db556cfb48d8c2e2fb0e327eeaaa9af6023112d3ebfdde613911cc459d54c23c60221dc5f55ce6ac40e288d7b33a027
|
data/lib/rbbt/monitor.rb
CHANGED
@@ -2,7 +2,9 @@ require 'rbbt'
|
|
2
2
|
|
3
3
|
module Rbbt
|
4
4
|
|
5
|
-
LOCK_DIRS
|
5
|
+
LOCK_DIRS = Rbbt.share.find_all + Rbbt.var.cache.persistence.find_all + Rbbt.var.jobs.find_all +
|
6
|
+
Rbbt.tmp.tsv_open_locks.find_all + Rbbt.tmp.persist_locks.find_all
|
7
|
+
|
6
8
|
def self.locks(dirs = LOCK_DIRS)
|
7
9
|
dirs.collect do |dir|
|
8
10
|
dir.glob("**/*.lock")
|
data/lib/rbbt/persist.rb
CHANGED
@@ -18,7 +18,7 @@ module Persist
|
|
18
18
|
attr_accessor :lock_dir
|
19
19
|
|
20
20
|
def lock_dir
|
21
|
-
@lock_dir ||= Rbbt.tmp.
|
21
|
+
@lock_dir ||= Rbbt.tmp.persist_locks.find
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -282,11 +282,13 @@ module Persist
|
|
282
282
|
|
283
283
|
def self.get_result(path, type, persist_options, lockfile, &block)
|
284
284
|
res = yield
|
285
|
+
stream = res if IO === res
|
286
|
+
stream = res.stream if res.respond_to? :stream
|
287
|
+
|
288
|
+
if stream
|
289
|
+
if persist_options[:no_load] == :stream
|
290
|
+
res = tee_stream(stream, path, type, stream.respond_to?(:callback)? stream.callback : nil, stream.respond_to?(:abort_callback)? stream.abort_callback : nil)
|
285
291
|
|
286
|
-
if persist_options[:no_load] == :stream
|
287
|
-
case res
|
288
|
-
when IO
|
289
|
-
res = tee_stream(res, path, type, res.respond_to?(:callback)? res.callback : nil, res.respond_to?(:abort_callback)? res.abort_callback : nil)
|
290
292
|
ConcurrentStream.setup res do
|
291
293
|
begin
|
292
294
|
lockfile.unlock #if File.exists? lockfile.path and lockfile.locked?
|
@@ -302,27 +304,50 @@ module Persist
|
|
302
304
|
end
|
303
305
|
end
|
304
306
|
raise KeepLocked.new res
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
307
|
+
else
|
308
|
+
begin
|
309
|
+
res = case type
|
310
|
+
when :array
|
311
|
+
res.read.split "\n"
|
312
|
+
when :tsv
|
313
|
+
TSV.open(res)
|
314
|
+
else
|
315
|
+
res.read
|
316
|
+
end
|
317
|
+
res.join if res.respond_to? :join
|
318
|
+
res
|
319
|
+
rescue
|
320
|
+
res.abort if res.respond_to? :abort
|
321
|
+
raise $!
|
315
322
|
end
|
316
|
-
|
317
|
-
|
318
|
-
|
323
|
+
end
|
324
|
+
else
|
325
|
+
res
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
def self._get_result(path, type, persist_options, lockfile, &block)
|
330
|
+
res = yield
|
331
|
+
|
332
|
+
if persist_options[:no_load] == :stream
|
333
|
+
stream = IO === res ? res : res.stream
|
334
|
+
res = tee_stream(stream, path, type, stream.respond_to?(:callback)? stream.callback : nil, stream.respond_to?(:abort_callback)? stream.abort_callback : nil)
|
335
|
+
|
336
|
+
ConcurrentStream.setup res do
|
337
|
+
begin
|
319
338
|
lockfile.unlock #if File.exists? lockfile.path and lockfile.locked?
|
320
|
-
|
321
|
-
|
322
|
-
end
|
339
|
+
rescue Exception
|
340
|
+
Log.medium "Lockfile exception: " << $!.message
|
323
341
|
end
|
324
|
-
raise KeepLocked.new res
|
325
342
|
end
|
343
|
+
res.abort_callback = Proc.new do
|
344
|
+
begin
|
345
|
+
lockfile.unlock #if File.exists? lockfile.path and lockfile.locked?
|
346
|
+
rescue Exception
|
347
|
+
Log.medium "Lockfile exception: " << $!.message
|
348
|
+
end
|
349
|
+
end
|
350
|
+
raise KeepLocked.new res
|
326
351
|
end
|
327
352
|
|
328
353
|
case res
|
@@ -356,24 +381,29 @@ module Persist
|
|
356
381
|
|
357
382
|
def self.persist_file(path, type, persist_options, &block)
|
358
383
|
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
384
|
+
begin
|
385
|
+
if is_persisted?(path, persist_options)
|
386
|
+
Log.low "Persist up-to-date: #{ path } - #{Misc.fingerprint persist_options}"
|
387
|
+
return path if persist_options[:no_load]
|
388
|
+
return load_file(path, type)
|
389
|
+
else
|
390
|
+
Open.rm path if Open.exists? path
|
391
|
+
end
|
392
|
+
rescue Exception
|
364
393
|
Open.rm path if Open.exists? path
|
365
394
|
end
|
366
395
|
|
367
396
|
|
397
|
+
lock_filename = Persist.persistence_path(path + '.persist', {:dir => Persist.lock_dir})
|
368
398
|
begin
|
369
|
-
|
370
|
-
lock_filename = Persist.persistence_path(path + '.persist', {:dir => Persist.lock_dir})
|
371
399
|
Misc.lock lock_filename do |lockfile|
|
372
400
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
401
|
+
Misc.insist do
|
402
|
+
if is_persisted?(path, persist_options)
|
403
|
+
Log.low "Persist up-to-date (suddenly): #{ path } - #{Misc.fingerprint persist_options}"
|
404
|
+
return path if persist_options[:no_load]
|
405
|
+
return load_file(path, type)
|
406
|
+
end
|
377
407
|
end
|
378
408
|
|
379
409
|
Log.medium "Persist create: #{ path } - #{type} #{Misc.fingerprint persist_options}"
|
@@ -387,8 +417,12 @@ module Persist
|
|
387
417
|
persist_options[:no_load] ? path : res
|
388
418
|
end
|
389
419
|
|
390
|
-
rescue
|
420
|
+
rescue Lockfile::StolenLockError
|
421
|
+
Log.medium "Lockfile stolen: #{path}"
|
422
|
+
retry
|
423
|
+
rescue Exception
|
391
424
|
Log.medium "Error in persist: #{path}#{Open.exists?(path) ? Log.color(:red, " Erasing") : ""}"
|
425
|
+
Log.exception $!
|
392
426
|
FileUtils.rm path if Open.exists? path
|
393
427
|
raise $!
|
394
428
|
end
|
data/lib/rbbt/tsv.rb
CHANGED
@@ -62,7 +62,7 @@ module TSV
|
|
62
62
|
|
63
63
|
data = nil
|
64
64
|
|
65
|
-
lock_filename = filename.nil? ? nil : Persist.persistence_path(filename, {:dir => TSV.lock_dir})
|
65
|
+
lock_filename = filename.nil? ? nil : Persist.persistence_path(filename + '.open', {:dir => TSV.lock_dir})
|
66
66
|
Misc.lock lock_filename do
|
67
67
|
data = Persist.persist_tsv source, filename, options, persist_options do |data|
|
68
68
|
if serializer
|
@@ -61,7 +61,12 @@ class RbbtProcessQueue
|
|
61
61
|
rescue Aborted
|
62
62
|
Log.warn "Aborting process monitor"
|
63
63
|
@processes.each{|p| p.abort }
|
64
|
-
@processes.each{|p|
|
64
|
+
@processes.each{|p|
|
65
|
+
begin
|
66
|
+
p.join
|
67
|
+
rescue ProcessFailed
|
68
|
+
end
|
69
|
+
}
|
65
70
|
rescue Exception
|
66
71
|
Log.warn "Process monitor exception: #{$!.message}"
|
67
72
|
@processes.each{|p| p.abort }
|
@@ -114,7 +119,10 @@ class RbbtProcessQueue
|
|
114
119
|
(@process_monitor.raise(Aborted.new); @process_monitor.join) if @process_monitor and @process_monitor.alive?
|
115
120
|
(@callback_thread.raise(Aborted.new); @callback_thread.join) if @callback_thread and @callback_thread.alive?
|
116
121
|
ensure
|
117
|
-
|
122
|
+
begin
|
123
|
+
join
|
124
|
+
rescue ProcessFailed
|
125
|
+
end
|
118
126
|
end
|
119
127
|
end
|
120
128
|
|
@@ -33,8 +33,10 @@ class RbbtProcessQueue
|
|
33
33
|
rescue ClosedStream
|
34
34
|
rescue Aborted, Interrupt
|
35
35
|
Log.warn "Worker #{Process.pid} aborted"
|
36
|
-
Kernel.exit!
|
36
|
+
Kernel.exit! 0
|
37
|
+
#Kernel.exit! -1
|
37
38
|
rescue Exception
|
39
|
+
Log.exception $!
|
38
40
|
@callback_queue.push($!) if @callback_queue
|
39
41
|
Kernel.exit! -1
|
40
42
|
ensure
|
@@ -44,7 +46,8 @@ class RbbtProcessQueue
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def join
|
47
|
-
|
49
|
+
Process.waitpid @pid
|
50
|
+
raise ProcessFailed unless $?.success?
|
48
51
|
end
|
49
52
|
|
50
53
|
def abort
|
@@ -125,6 +125,12 @@ module Misc
|
|
125
125
|
try = 0
|
126
126
|
begin
|
127
127
|
yield
|
128
|
+
rescue Aborted
|
129
|
+
if msg
|
130
|
+
Log.warn("Not Insisting after Aborted: #{$!.message} -- #{msg}")
|
131
|
+
else
|
132
|
+
Log.warn("Not Insisting after Aborted: #{$!.message}")
|
133
|
+
end
|
128
134
|
rescue Exception
|
129
135
|
if msg
|
130
136
|
Log.warn("Insisting after exception: #{$!.message} -- #{msg}")
|
data/lib/rbbt/util/misc/lock.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
if ENV["RBBT_NO_LOCKFILE_REFRESH"] == "true"
|
2
2
|
Lockfile.refresh = false
|
3
3
|
Lockfile.max_age = 60 * 60 * 5
|
4
|
+
Lockfile.max_age = 15
|
5
|
+
Lockfile.suspend = 10
|
4
6
|
else
|
7
|
+
Lockfile.dont_use_lock_id = true
|
5
8
|
Lockfile.refresh = 5
|
6
|
-
Lockfile.max_age =
|
7
|
-
Lockfile.suspend =
|
9
|
+
Lockfile.max_age = 60
|
10
|
+
Lockfile.suspend = 15
|
8
11
|
end
|
9
12
|
|
13
|
+
|
10
14
|
module Misc
|
11
15
|
|
12
16
|
LOCK_MUTEX = Mutex.new
|
@@ -19,40 +23,16 @@ module Misc
|
|
19
23
|
lock_path = File.expand_path(file + '.lock')
|
20
24
|
lockfile = Lockfile.new(lock_path, options)
|
21
25
|
|
22
|
-
|
23
|
-
LOCK_MUTEX.synchronize do
|
24
|
-
Misc.insist 2, 0.1 do
|
25
|
-
Misc.insist 3, 0.1 do
|
26
|
-
begin
|
27
|
-
if File.exists? lock_path
|
28
|
-
info = Open.open(lock_path){|f| YAML.load(f) }
|
29
|
-
raise "No info" unless info
|
30
|
-
|
31
|
-
if hostname == info["host"] and not Misc.pid_exists?(info["pid"])
|
32
|
-
Log.high("Removing lockfile: #{lock_path}. This pid #{Process.pid}. Content: #{info.inspect}")
|
33
|
-
|
34
|
-
FileUtils.rm lock_path
|
35
|
-
end
|
36
|
-
end
|
37
|
-
rescue Exception
|
38
|
-
FileUtils.rm lock_path if File.exists? lock_path
|
39
|
-
lockfile = Lockfile.new(lock_path, options) unless File.exists? lock_path
|
40
|
-
raise $!
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
lockfile.lock
|
45
|
-
end
|
26
|
+
lockfile.lock
|
46
27
|
|
47
28
|
begin
|
48
29
|
res = yield lockfile
|
49
|
-
rescue Lockfile::StolenLockError
|
50
|
-
unlock = false
|
30
|
+
#rescue Lockfile::StolenLockError
|
51
31
|
rescue KeepLocked
|
52
32
|
unlock = false
|
53
33
|
res = $!.payload
|
54
34
|
rescue Exception
|
55
|
-
lockfile.unlock if lockfile.locked?
|
35
|
+
lockfile.unlock #if lockfile.locked?
|
56
36
|
raise $!
|
57
37
|
ensure
|
58
38
|
if unlock
|
data/lib/rbbt/util/misc/pipes.rb
CHANGED
@@ -201,6 +201,7 @@ module Misc
|
|
201
201
|
return if Open.exists? path
|
202
202
|
tmp_path = Persist.persistence_path(path, {:dir => Misc.sensiblewrite_dir})
|
203
203
|
Misc.lock tmp_path do
|
204
|
+
return if Open.exists? path
|
204
205
|
if not Open.exists? path
|
205
206
|
FileUtils.rm_f tmp_path if File.exists? tmp_path
|
206
207
|
begin
|
data/lib/rbbt/util/open.rb
CHANGED
@@ -377,12 +377,13 @@ module Open
|
|
377
377
|
if block_given?
|
378
378
|
begin
|
379
379
|
return yield(io)
|
380
|
-
rescue
|
380
|
+
rescue Exception
|
381
381
|
io.abort if io.respond_to? :abort
|
382
382
|
io.join if io.respond_to? :join
|
383
383
|
raise $!
|
384
384
|
ensure
|
385
385
|
io.join if io.respond_to? :join
|
386
|
+
io.close if io.respond_to? :close and not io.closed?
|
386
387
|
end
|
387
388
|
else
|
388
389
|
io
|
@@ -5,6 +5,10 @@ class Step
|
|
5
5
|
|
6
6
|
INFO_SERIALIAZER = Marshal
|
7
7
|
|
8
|
+
def self.started?
|
9
|
+
info_file.exists?
|
10
|
+
end
|
11
|
+
|
8
12
|
def self.wait_for_jobs(jobs)
|
9
13
|
begin
|
10
14
|
threads = []
|
@@ -465,7 +469,7 @@ module Workflow
|
|
465
469
|
|
466
470
|
TAG = :hash
|
467
471
|
def step_path(taskname, jobname, inputs, dependencies, extension = nil)
|
468
|
-
Proc.new{
|
472
|
+
#Proc.new{
|
469
473
|
raise "Jobname makes an invalid path: #{ jobname }" if jobname =~ /\.\./
|
470
474
|
if inputs.any? or dependencies.any?
|
471
475
|
tagged_jobname = case TAG
|
@@ -486,7 +490,7 @@ module Workflow
|
|
486
490
|
end
|
487
491
|
|
488
492
|
workdir[taskname][tagged_jobname].find
|
489
|
-
}
|
493
|
+
#}
|
490
494
|
end
|
491
495
|
|
492
496
|
def id_for(path)
|
data/lib/rbbt/workflow/step.rb
CHANGED
@@ -143,8 +143,8 @@ class Step
|
|
143
143
|
dependency.clean if (dependency.error? or dependency.aborted? or dependency.status.nil?)# or not dependency.done?)
|
144
144
|
end
|
145
145
|
|
146
|
-
unless dependency.result or dependency.done?
|
147
|
-
dependency.run(true)
|
146
|
+
unless dependency.started? #dependency.result or dependency.done?
|
147
|
+
dependency.run(true)#.grace
|
148
148
|
end
|
149
149
|
rescue Aborted
|
150
150
|
Log.error "Aborted dep. #{Log.color :red, dependency.task.name.to_s}"
|
@@ -18,8 +18,6 @@ EOF
|
|
18
18
|
rbbt_usage and exit 0 if options[:help]
|
19
19
|
|
20
20
|
locks = Rbbt.locks
|
21
|
-
sensiblewrites = Rbbt.sensiblewrites
|
22
|
-
persists = Rbbt.persists
|
23
21
|
|
24
22
|
puts Log.color(:magenta, "# System clean")
|
25
23
|
puts
|
@@ -27,14 +25,15 @@ if locks.any?
|
|
27
25
|
puts Log.color(:magenta, "Locks: #{locks.length}")
|
28
26
|
locks.each do |lock|
|
29
27
|
pid, ppid, time = Rbbt.load_lock(lock)
|
30
|
-
if not Misc.pid_exists? pid
|
28
|
+
if File.exists?(lock) and not Misc.pid_exists? pid
|
31
29
|
puts " Removing #{ lock }"
|
32
|
-
FileUtils.rm lock if File.exists? lock
|
30
|
+
FileUtils.rm lock #if File.exists? lock
|
33
31
|
end
|
34
32
|
end
|
35
33
|
puts
|
36
34
|
end
|
37
35
|
|
36
|
+
persists = Rbbt.persists
|
38
37
|
if persists.any?
|
39
38
|
puts Log.color(:magenta, "Persist: #{persists.length}")
|
40
39
|
persists.each do |persist|
|
@@ -49,6 +48,7 @@ if persists.any?
|
|
49
48
|
puts
|
50
49
|
end
|
51
50
|
|
51
|
+
sensiblewrites = Rbbt.sensiblewrites
|
52
52
|
if sensiblewrites.any?
|
53
53
|
puts Log.color(:magenta, "Writing: #{sensiblewrites.length}")
|
54
54
|
sensiblewrites.each do |sensiblewrite|
|
@@ -65,7 +65,7 @@ end
|
|
65
65
|
|
66
66
|
jobs = Rbbt.jobs
|
67
67
|
|
68
|
-
puts Log.color(:magenta, "#
|
68
|
+
puts Log.color(:magenta, "# Workflow clean")
|
69
69
|
puts
|
70
70
|
jobs.each do |workflow, tasks|
|
71
71
|
tasks.each do |task, jobs|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbbt-util'
|
4
|
+
require 'rbbt/util/simpleopt'
|
5
|
+
require 'rbbt/workflow'
|
6
|
+
require 'rbbt/monitor'
|
7
|
+
|
8
|
+
$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
|
9
|
+
|
10
|
+
options = SOPT.setup <<EOF
|
11
|
+
|
12
|
+
Find process with deleted open files
|
13
|
+
|
14
|
+
$ rbbt system deleted_files
|
15
|
+
|
16
|
+
-h--help Print this help
|
17
|
+
EOF
|
18
|
+
rbbt_usage and exit 0 if options[:help]
|
19
|
+
|
20
|
+
pids = {}
|
21
|
+
Dir.glob('/proc/*/fd/*').each do |file|
|
22
|
+
pid = file.split('/')[-3]
|
23
|
+
begin
|
24
|
+
dest = File.readlink(file)
|
25
|
+
rescue
|
26
|
+
next
|
27
|
+
end
|
28
|
+
next if File.exists? dest
|
29
|
+
pids[pid] ||= []
|
30
|
+
pids[pid] << dest
|
31
|
+
end
|
32
|
+
|
33
|
+
pids.sort_by{|p,files| files.length}.each do |pid,files|
|
34
|
+
dirs = {}
|
35
|
+
files.each do |f|
|
36
|
+
name = File.basename(f)
|
37
|
+
dir = File.basename(File.dirname(f))
|
38
|
+
next if dir =~ /^pts|\.$/
|
39
|
+
dirs[dir] ||= []
|
40
|
+
dirs[dir] << name
|
41
|
+
end
|
42
|
+
next if dirs.empty?
|
43
|
+
puts Log.color :magenta, pid
|
44
|
+
dirs.sort_by{|dir,list| list.length}.each do |dir,list|
|
45
|
+
puts Misc.format_definition_list_item(dir, list.length.to_s)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "Total: #{pids.values.collect{|k,v| v}.flatten.length}"
|
@@ -13,12 +13,12 @@ Report the status of the system
|
|
13
13
|
|
14
14
|
$ rbbt system status
|
15
15
|
|
16
|
-
-
|
16
|
+
-a--all Print all jobs, not only uncompleted
|
17
17
|
-h--help Print this help
|
18
18
|
EOF
|
19
19
|
rbbt_usage and exit 0 if options[:help]
|
20
20
|
|
21
|
-
|
21
|
+
all = options.delete :all
|
22
22
|
|
23
23
|
def pid_msg(pid)
|
24
24
|
color = if pid and Misc.pid_exists? pid
|
@@ -51,12 +51,10 @@ def status_msg(status)
|
|
51
51
|
Log.color(color, status.to_s)
|
52
52
|
end
|
53
53
|
|
54
|
-
locks = Rbbt.locks
|
55
|
-
sensiblewrites = Rbbt.sensiblewrites
|
56
|
-
persists = Rbbt.persists
|
57
|
-
|
58
54
|
puts Log.color(:magenta, "# System report")
|
59
55
|
puts
|
56
|
+
|
57
|
+
locks = Rbbt.locks
|
60
58
|
if locks.any?
|
61
59
|
puts Log.color(:magenta, "Locks:")
|
62
60
|
locks.sort_by{|f| File.exists?(f) ? File.ctime(f) : Time.now}.each do |lock|
|
@@ -68,6 +66,7 @@ if locks.any?
|
|
68
66
|
puts
|
69
67
|
end
|
70
68
|
|
69
|
+
persists = Rbbt.persists
|
71
70
|
if persists.any?
|
72
71
|
puts Log.color(:magenta, "Persist:")
|
73
72
|
persists.sort_by{|f| File.exists?(f) ? File.ctime(f) : Time.now}.each do |persist|
|
@@ -78,6 +77,7 @@ if persists.any?
|
|
78
77
|
puts
|
79
78
|
end
|
80
79
|
|
80
|
+
sensiblewrites = Rbbt.sensiblewrites
|
81
81
|
if sensiblewrites.any?
|
82
82
|
puts Log.color(:magenta, "Writing:")
|
83
83
|
sensiblewrites.sort_by{|f| File.exists?(f) ? File.ctime(f) : Time.now}.each do |sensiblewrite|
|
@@ -89,10 +89,10 @@ if sensiblewrites.any?
|
|
89
89
|
puts
|
90
90
|
end
|
91
91
|
|
92
|
-
jobs = Rbbt.jobs
|
93
92
|
|
94
93
|
puts Log.color(:magenta, "# Workflows")
|
95
|
-
|
94
|
+
|
95
|
+
jobs = Rbbt.jobs
|
96
96
|
jobs.each do |workflow, tasks|
|
97
97
|
tasks.each do |task, jobs|
|
98
98
|
done = []
|
@@ -106,7 +106,7 @@ jobs.each do |workflow, tasks|
|
|
106
106
|
other[status||"missing"] << [file, h[:pid]]
|
107
107
|
end
|
108
108
|
end
|
109
|
-
next if
|
109
|
+
next if not all and other.empty?
|
110
110
|
puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:cyan, task) << ": " << Log.color(:blue, done.length.to_s) << " done"
|
111
111
|
other.each do |status, list|
|
112
112
|
files_txt = list.collect{|f,p| p.nil? ? f : (f + " (#{pid_msg p})") }
|
@@ -2,30 +2,77 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_he
|
|
2
2
|
|
3
3
|
require 'rbbt-util'
|
4
4
|
require 'rbbt/util/misc/lock'
|
5
|
+
require 'rbbt/workflow'
|
5
6
|
|
6
7
|
class TestLock < Test::Unit::TestCase
|
7
8
|
def __test_stress
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
if __FILE__ == $0
|
13
|
+
def deleted(pid = Process.pid)
|
14
|
+
begin
|
15
|
+
txt = `ls -la /proc/#{pid}/fd |grep deleted`
|
16
|
+
puts Log.color(:magenta, [pid, txt.split("\n")*", "] * ": ")
|
17
|
+
rescue Exception
|
18
|
+
Log.exception $!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
cpus = 10
|
23
|
+
file = "/tmp/test.lock"
|
24
|
+
|
25
|
+
pids = []
|
26
|
+
cpus.times do
|
27
|
+
pids << Process.fork do
|
28
|
+
while true do
|
29
|
+
Lockfile.new file do
|
30
|
+
Lockfile.new file + '.1' do
|
18
31
|
end
|
32
|
+
File.open(file){|f| puts f.read }
|
33
|
+
end
|
34
|
+
deleted
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
exit
|
42
|
+
size = 1000000
|
43
|
+
num = 1
|
44
|
+
cpus = 5
|
19
45
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
46
|
+
pdb = "http://interactome3d.irbbarcelona.org/pdb.php?dataset=human&type1=interactions&type2=pdb&pdb=Q99685-Q99685-EXP-3hju.pdb1-B-0-A-0.pdb"
|
47
|
+
Workflow.require_workflow "Structure"
|
48
|
+
TmpFile.with_file do |dir|
|
49
|
+
Structure.workdir = dir
|
50
|
+
Path.setup dir
|
51
|
+
Log.severity = 4
|
52
|
+
TSV.traverse (0..size).to_a, :cpus => cpus, :type => :array, :bar => true do |i|
|
53
|
+
begin
|
54
|
+
v = rand(num).to_s
|
55
|
+
file = File.join(dir, "file-" << v.to_s)
|
56
|
+
|
57
|
+
Misc.lock file + '.produce' do
|
58
|
+
Misc.lock file do
|
59
|
+
##job = Structure.job(:neighbour_map, v, :pdb => pdb)
|
60
|
+
#job = Translation.example_step(:translate, "Example")
|
61
|
+
#job.path = file
|
62
|
+
#if job.done?
|
63
|
+
# job.clean if rand < 0.3
|
64
|
+
#else
|
65
|
+
# job.run(true)
|
66
|
+
#end
|
67
|
+
end
|
26
68
|
end
|
69
|
+
deleted Process.pid
|
70
|
+
|
71
|
+
rescue Exception
|
72
|
+
raise $!
|
27
73
|
end
|
28
74
|
end
|
29
75
|
end
|
30
76
|
end
|
31
77
|
|
78
|
+
|
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.13.
|
4
|
+
version: 5.13.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- share/rbbt_commands/stat/log
|
248
248
|
- share/rbbt_commands/study/task
|
249
249
|
- share/rbbt_commands/system/clean
|
250
|
+
- share/rbbt_commands/system/deleted_files
|
250
251
|
- share/rbbt_commands/system/purge
|
251
252
|
- share/rbbt_commands/system/report
|
252
253
|
- share/rbbt_commands/system/status
|