rbbt-util 5.13.35 → 5.13.36
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 +1 -0
- data/lib/rbbt/tsv/stream.rb +12 -10
- data/lib/rbbt/util/concurrency/processes/worker.rb +11 -7
- data/lib/rbbt/util/misc/concurrent_stream.rb +6 -9
- data/lib/rbbt/util/misc/development.rb +10 -0
- data/lib/rbbt/workflow.rb +1 -1
- data/lib/rbbt/workflow/step/run.rb +2 -1
- 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: 48414e48036dde6708ce828f47fa10e1169cf26c
|
4
|
+
data.tar.gz: 818bb5d1cf90da015d716050c9283821435eecbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a35a5de8c4870b10e86353030787fb261b7086eac2553e79b86609352d88d69d09f65246cbd07e43f65d1a9bf863c0f00e070c9f380b4f2ae1d541b6f89f61a9
|
7
|
+
data.tar.gz: e649af70a02eb33d3a3255766bf495197baa48d0274fa3a6b8e723a43daa4f8dc497e7aa781291ad83d75b6a50fa4f2913a1530bb9924147ecd670c4ce672fc5
|
data/lib/rbbt/persist.rb
CHANGED
data/lib/rbbt/tsv/stream.rb
CHANGED
@@ -57,22 +57,22 @@ module TSV
|
|
57
57
|
options = Misc.add_defaults options, :sep => "\t", :sort => true
|
58
58
|
sort, sep = Misc.process_options options, :sort, :sep
|
59
59
|
|
60
|
-
|
60
|
+
streams = streams.collect do |stream|
|
61
|
+
if defined? Step and Step === stream
|
62
|
+
stream.grace
|
63
|
+
stream.get_stream || stream.join.path.open
|
64
|
+
else
|
65
|
+
stream
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
out = Misc.open_pipe do |sin|
|
61
70
|
num_streams = streams.length
|
62
71
|
|
63
|
-
streams = streams.collect do |stream|
|
64
|
-
if defined? Step and Step === stream
|
65
|
-
stream.grace
|
66
|
-
stream.get_stream || stream.join.path.open
|
67
|
-
else
|
68
|
-
stream
|
69
|
-
end
|
70
|
-
end
|
71
72
|
|
72
73
|
streams = streams.collect do |stream|
|
73
74
|
sorted = Misc.sort_stream(stream)
|
74
75
|
stream.annotate sorted if stream.respond_to? :annotate
|
75
|
-
stream.clear if stream.respond_to? :annotate
|
76
76
|
sorted
|
77
77
|
end if sort
|
78
78
|
|
@@ -161,5 +161,7 @@ module TSV
|
|
161
161
|
raise $!
|
162
162
|
end
|
163
163
|
end
|
164
|
+
|
165
|
+
out
|
164
166
|
end
|
165
167
|
end
|
@@ -7,13 +7,17 @@ class RbbtProcessQueue
|
|
7
7
|
|
8
8
|
@pid = Process.fork do
|
9
9
|
begin
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
10
|
+
|
11
|
+
#Persist::CONNECTIONS.values.each do |db| db.close if db.write? end
|
12
|
+
#ObjectSpace.each_object(Mutex) do |m|
|
13
|
+
# begin
|
14
|
+
# m.unlock
|
15
|
+
# rescue ThreadError
|
16
|
+
# end if m.locked?
|
17
|
+
#end
|
18
|
+
|
19
|
+
Misc.pre_fork
|
20
|
+
|
17
21
|
@cleanup.call if @cleanup
|
18
22
|
@queue.close_write
|
19
23
|
|
@@ -2,7 +2,7 @@ module ConcurrentStream
|
|
2
2
|
attr_accessor :threads, :pids, :callback, :abort_callback, :filename, :joined, :aborted, :autojoin, :lockfile
|
3
3
|
|
4
4
|
def self.setup(stream, options = {}, &block)
|
5
|
-
threads, pids, callback, filename, autojoin = Misc.process_options options, :threads, :pids, :callback, :filename, :autojoin
|
5
|
+
threads, pids, callback, filename, autojoin, lockfile = Misc.process_options options, :threads, :pids, :callback, :filename, :autojoin, :lockfile
|
6
6
|
stream.extend ConcurrentStream unless ConcurrentStream === stream
|
7
7
|
|
8
8
|
stream.threads ||= []
|
@@ -24,18 +24,13 @@ module ConcurrentStream
|
|
24
24
|
|
25
25
|
stream.filename = filename unless filename.nil?
|
26
26
|
|
27
|
+
stream.lockfile = lockfile if lockfile
|
28
|
+
|
27
29
|
stream
|
28
30
|
end
|
29
31
|
|
30
32
|
def annotate(stream)
|
31
|
-
ConcurrentStream.setup
|
32
|
-
stream.threads = threads
|
33
|
-
stream.pids = pids
|
34
|
-
stream.callback = callback
|
35
|
-
stream.abort_callback = abort_callback
|
36
|
-
stream.filename = filename
|
37
|
-
stream.autojoin = autojoin
|
38
|
-
stream.joined = joined
|
33
|
+
ConcurrentStream.setup(stream, :threads => threads, :pids => pids, :callback => callback, :abort_callback => abort_callback, :filename => filename, :autojoin => autojoin, :lockfile => lockfile)
|
39
34
|
stream
|
40
35
|
end
|
41
36
|
|
@@ -138,6 +133,8 @@ module ConcurrentStream
|
|
138
133
|
|
139
134
|
abort_threads
|
140
135
|
abort_pids
|
136
|
+
iii [:abort, lockfile]
|
137
|
+
lockfile.unlock if lockfile and lockfile.locked?
|
141
138
|
end
|
142
139
|
Log.medium "Aborted stream #{Misc.fingerprint self} -- #{@abort_callback} [#{@aborted}]"
|
143
140
|
end
|
@@ -1,5 +1,15 @@
|
|
1
1
|
module Misc
|
2
2
|
|
3
|
+
def self.pre_fork
|
4
|
+
Persist::CONNECTIONS.values.each do |db| db.close if db.write? end
|
5
|
+
ObjectSpace.each_object(Mutex) do |m|
|
6
|
+
begin
|
7
|
+
m.unlock
|
8
|
+
rescue ThreadError
|
9
|
+
end if m.locked?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
3
13
|
def self.string2const(string)
|
4
14
|
return nil if string.nil?
|
5
15
|
mod = Kernel
|
data/lib/rbbt/workflow.rb
CHANGED
@@ -92,7 +92,7 @@ class Step
|
|
92
92
|
@result = self._exec
|
93
93
|
@result = @result.stream if TSV::Dumper === @result
|
94
94
|
end
|
95
|
-
no_load or ENV["RBBT_NO_STREAM"] ? @result : prepare_result(@result, @task.result_description)
|
95
|
+
(no_load or ENV["RBBT_NO_STREAM"]) ? @result : prepare_result(@result, @task.result_description)
|
96
96
|
end
|
97
97
|
|
98
98
|
def checks
|
@@ -273,6 +273,7 @@ class Step
|
|
273
273
|
def fork(semaphore = nil)
|
274
274
|
raise "Can not fork: Step is waiting for proces #{@pid} to finish" if not @pid.nil? and not Process.pid == @pid and Misc.pid_exists?(@pid) and not done? and info[:forked]
|
275
275
|
@pid = Process.fork do
|
276
|
+
Misc.pre_fork
|
276
277
|
begin
|
277
278
|
RbbtSemaphore.wait_semaphore(semaphore) if semaphore
|
278
279
|
FileUtils.mkdir_p File.dirname(path) unless Open.exists? File.dirname(path)
|