rbbt-util 5.13.35 → 5.13.36

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81458a4ac4aaf570ca085039bc9edef474939dcf
4
- data.tar.gz: 0347d3cdb338145d6633126373eaad1430aaea79
3
+ metadata.gz: 48414e48036dde6708ce828f47fa10e1169cf26c
4
+ data.tar.gz: 818bb5d1cf90da015d716050c9283821435eecbf
5
5
  SHA512:
6
- metadata.gz: f3eed434127735a837685ffd0ceb170c4e05988cdb02cab6626d63b1c7f4968f62ceff494bf50a18ad10baef182a9cea2b4f135b2fef21814d472aaf7b7ffd73
7
- data.tar.gz: 6c212fb6f2cd6a28ff2e45a3fcceffccc571a02f802f45627c0b7299b2df38461eb8181434ac7a21caf83b9c1855a2d51d1fdb9f7a9b27501bcc5b84b3481232
6
+ metadata.gz: a35a5de8c4870b10e86353030787fb261b7086eac2553e79b86609352d88d69d09f65246cbd07e43f65d1a9bf863c0f00e070c9f380b4f2ae1d541b6f89f61a9
7
+ data.tar.gz: e649af70a02eb33d3a3255766bf495197baa48d0274fa3a6b8e723a43daa4f8dc497e7aa781291ad83d75b6a50fa4f2913a1530bb9924147ecd670c4ce672fc5
data/lib/rbbt/persist.rb CHANGED
@@ -204,6 +204,7 @@ module Persist
204
204
  ConcurrentStream.setup(out, :threads => saver_thread, :filename => path)
205
205
  out.callback = callback
206
206
  out.abort_callback = abort_callback
207
+ out.lockfile = stream.lockfile
207
208
  out
208
209
  end
209
210
 
@@ -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
- Misc.open_pipe do |sin|
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
- Persist::CONNECTIONS.values.each do |db| db.close if db.write? end
11
- ObjectSpace.each_object(Mutex) do |m|
12
- begin
13
- m.unlock
14
- rescue ThreadError
15
- end if m.locked?
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 stream
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
@@ -238,7 +238,7 @@ module Workflow
238
238
  m = Module.new
239
239
 
240
240
  helpers.each do |name,block|
241
- m.class.send(:define_method, name, &block)
241
+ m.send(:define_method, name, &block)
242
242
  end
243
243
 
244
244
  m
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.13.35
4
+ version: 5.13.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez