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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d760f1f213971dc97e6eeef8759269b2f73572e3
4
- data.tar.gz: a50b3d2e09579bb30f39a1bcb1c9af5d2a433248
3
+ metadata.gz: ed4dc92acd6566d623035a51532d94c6b4eb2586
4
+ data.tar.gz: c157a15976ed4ead4f2049fad070b4fae96be54c
5
5
  SHA512:
6
- metadata.gz: 571f41f9f17350346888a4eb77e7434374599557bb11a0c18d359c16f14942712fbc21f03d9af4d75c0735a2802010aa0040af8558a7c0a2eb8631b4e4141dc7
7
- data.tar.gz: 80c28ff3598abeb9a3374afc3d9b29fb7a34f729d3f6f7e7ed2a985769bb08510daa2db5316e658d63d85082ca482baa2e7618e710903f7cc3ff97ae0438b7c5
6
+ metadata.gz: 700c4e7864a361db22527bc3bbe0f81584e3459a2be1d609a060cf21d63d3016d9afa68d6b71536be90fe7abf6da906a8c9364e255355c1ce2031cd774ecfa7b
7
+ data.tar.gz: 8571f6db42d6447788111a01362d3d578acaa5e8b7eef867e666020a2788d9b255c304341c21b9f31444cc7087df9cf5a76074e7245c642a3ad939076c98081d
@@ -143,27 +143,27 @@ module ZTK
143
143
  parent_writer.close
144
144
  parent_reader.close
145
145
 
146
- ::Timeout.timeout(config.child_timeout, ZTK::Parallel::Timeout) do
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
- data = nil
150
- begin
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
- if !data.nil?
161
- config.ui.logger.debug { "write(#{data.inspect})" }
162
- begin
163
- child_writer.write(Base64.encode64(Marshal.dump(data)))
164
- rescue Exception => e
165
- config.ui.logger.warn { "Exception while writing data to child_writer! - #{e.inspect}" }
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
@@ -1,6 +1,6 @@
1
1
  module ZTK
2
2
 
3
3
  # ZTK Version String
4
- VERSION = "3.2.4"
4
+ VERSION = "3.2.5"
5
5
 
6
6
  end
@@ -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
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-07 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport