ztk 3.2.4 → 3.2.5
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 +4 -4
- data/lib/ztk/parallel.rb +18 -18
- data/lib/ztk/version.rb +1 -1
- data/spec/ztk/parallel_spec.rb +12 -0
- 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: ed4dc92acd6566d623035a51532d94c6b4eb2586
|
4
|
+
data.tar.gz: c157a15976ed4ead4f2049fad070b4fae96be54c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 700c4e7864a361db22527bc3bbe0f81584e3459a2be1d609a060cf21d63d3016d9afa68d6b71536be90fe7abf6da906a8c9364e255355c1ce2031cd774ecfa7b
|
7
|
+
data.tar.gz: 8571f6db42d6447788111a01362d3d578acaa5e8b7eef867e666020a2788d9b255c304341c21b9f31444cc7087df9cf5a76074e7245c642a3ad939076c98081d
|
data/lib/ztk/parallel.rb
CHANGED
@@ -143,27 +143,27 @@ module ZTK
|
|
143
143
|
parent_writer.close
|
144
144
|
parent_reader.close
|
145
145
|
|
146
|
-
|
147
|
-
config.after_fork and config.after_fork.call(Process.pid)
|
146
|
+
config.after_fork and config.after_fork.call(Process.pid)
|
148
147
|
|
149
|
-
|
150
|
-
|
148
|
+
data = nil
|
149
|
+
begin
|
150
|
+
::Timeout.timeout(config.child_timeout, ZTK::Parallel::Timeout) do
|
151
151
|
data = block.call
|
152
|
-
rescue Exception => e
|
153
|
-
config.ui.logger.fatal { e.message }
|
154
|
-
e.backtrace.each do |line|
|
155
|
-
config.ui.logger << "#{line}\n"
|
156
|
-
end
|
157
|
-
data = ExceptionWrapper.new(e)
|
158
152
|
end
|
153
|
+
rescue Exception => e
|
154
|
+
config.ui.logger.fatal { e.message }
|
155
|
+
e.backtrace.each do |line|
|
156
|
+
config.ui.logger << "#{line}\n"
|
157
|
+
end
|
158
|
+
data = ExceptionWrapper.new(e)
|
159
|
+
end
|
159
160
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
end
|
161
|
+
if !data.nil?
|
162
|
+
config.ui.logger.debug { "write(#{data.inspect})" }
|
163
|
+
begin
|
164
|
+
child_writer.write(Base64.encode64(Marshal.dump(data)))
|
165
|
+
rescue Exception => e
|
166
|
+
config.ui.logger.warn { "Exception while writing data to child_writer! - #{e.inspect}" }
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -267,7 +267,7 @@ module ZTK
|
|
267
267
|
def process_data(data)
|
268
268
|
return data if !(ZTK::Parallel::ExceptionWrapper === data)
|
269
269
|
|
270
|
-
if ((config.raise_exceptions == true) || (ZTK::Parallel::Break === data.exception))
|
270
|
+
if ((config.raise_exceptions == true) || (ZTK::Parallel::Break === data.exception) || (ZTK::Parallel::Timeout === data.exception))
|
271
271
|
config.ui.logger.fatal { "exception(#{data.exception.inspect})" }
|
272
272
|
signal_all
|
273
273
|
raise data.exception
|
data/lib/ztk/version.rb
CHANGED
data/spec/ztk/parallel_spec.rb
CHANGED
@@ -110,6 +110,18 @@ describe ZTK::Parallel do
|
|
110
110
|
end.to raise_error ZTK::Parallel::Break
|
111
111
|
end
|
112
112
|
|
113
|
+
it "should raise ZTK::Parallel::Timeout if execution is longer than the limit set" do
|
114
|
+
subject = ZTK::Parallel.new(:raise_exceptions => false, :child_timeout => 3)
|
115
|
+
|
116
|
+
expect do
|
117
|
+
subject.process do
|
118
|
+
sleep 10
|
119
|
+
end
|
120
|
+
|
121
|
+
subject.waitall
|
122
|
+
end.to raise_error ZTK::Parallel::Timeout
|
123
|
+
end
|
124
|
+
|
113
125
|
end
|
114
126
|
|
115
127
|
describe "#wait" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Patten
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|