asynchronic 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5e63019f4cecfab21e005adaf3f0ca4cb18fac6
4
- data.tar.gz: 208ef42aa7f3b6ed1a395650d09944b53e8d425d
3
+ metadata.gz: df76d108620383f31881d300c27a58c8ed159ed5
4
+ data.tar.gz: 999c8387fca556bed70fc2ac5578a83e1ebc9156
5
5
  SHA512:
6
- metadata.gz: ff558de68371b4af458784cb02fdf2ca97e712f3525670608f5c1008a66bcf4d32072f73b6c7e3efa824d8a03c1ed13acb97976c474290316d30847df0a7c198
7
- data.tar.gz: 86fcec1a2c20383b4dcc29dea9b1926f1b3ea52d61dabffe62482e7c3d1faefc872b48a9832c75afb3156af1cb335dd67709070726d2802e308d2f1323c0fe3c
6
+ metadata.gz: fe94f5bdce4c457d78d0c46653d8299b23f7ae9ecff911f3d321572921c694e4e96265cbb9c65cd0fc6d925740c4697118fe0222ff3db97a58b4c8874ff2dcbf
7
+ data.tar.gz: 0dc6bbd6de6502feee5003452381d18413ede5492ba3a173eba522e2a4080178bce9379f0f1f3efcfe29dfcb92dec47eb98e795f6c2aa384456c3c3713f80b3c
data/lib/asynchronic.rb CHANGED
@@ -35,7 +35,7 @@ module Asynchronic
35
35
  begin
36
36
  result = yield
37
37
  rescue Exception => ex
38
- logger.info(a_class) { "Retrying #{message}. ERROR: #{ex.message}" }
38
+ logger.error(a_class) { "Retrying #{message}. ERROR: #{ex.message}" }
39
39
  sleep RETRY_TIMEOUT
40
40
  retry
41
41
  end
@@ -85,21 +85,15 @@ module Asynchronic
85
85
  end
86
86
 
87
87
  def wakeup
88
- data_store.synchronize(id) do
89
- if waiting?
90
- if processes.any?(&:aborted?)
91
- abort! Error.new "Error caused by #{processes.select(&:aborted?).map{|p| p.name}.join(', ')}"
92
- elsif processes.all?(&:completed?)
93
- completed!
94
- else
95
- processes.each do |p|
96
- p.enqueue if p.ready?
97
- end
98
- end
99
- end
100
-
101
- parent.wakeup if parent && finalized?
88
+ Asynchronic.logger.info('Asynchronic') { "Wakeup started #{type} (#{id})" }
89
+ if environment.queue_engine.asynchronic?
90
+ data_store.synchronize(id) { wakeup_children }
91
+ else
92
+ wakeup_children
102
93
  end
94
+ Asynchronic.logger.info('Asynchronic') { "Wakeup finalized #{type} (#{id})" }
95
+
96
+ parent.wakeup if parent && finalized?
103
97
  end
104
98
 
105
99
  def nest(type, params={})
@@ -182,6 +176,20 @@ module Asynchronic
182
176
  end
183
177
  end
184
178
 
179
+ def wakeup_children
180
+ if waiting?
181
+ if processes.any?(&:aborted?)
182
+ abort! Error.new "Error caused by #{processes.select(&:aborted?).map{|p| p.name}.join(', ')}"
183
+ elsif processes.all?(&:completed?)
184
+ completed!
185
+ else
186
+ processes.each do |p|
187
+ p.enqueue if p.ready?
188
+ end
189
+ end
190
+ end
191
+ end
192
+
185
193
  def infer_dependencies(params)
186
194
  params.values.select { |v| v.respond_to?(:proxy?) && v.proxy_class == DataStore::LazyValue }
187
195
  .map { |v| Process.new(environment, v.data_store.scope).name }
@@ -29,6 +29,9 @@ module Asynchronic
29
29
  Listener.new
30
30
  end
31
31
 
32
+ def asynchronic?
33
+ true
34
+ end
32
35
 
33
36
  class Queue
34
37
 
@@ -31,6 +31,10 @@ module Asynchronic
31
31
  Listener.new
32
32
  end
33
33
 
34
+ def asynchronic?
35
+ true
36
+ end
37
+
34
38
  private
35
39
 
36
40
  def redis
@@ -25,6 +25,9 @@ module Asynchronic
25
25
  @stubs[job] = block
26
26
  end
27
27
 
28
+ def asynchronic?
29
+ false
30
+ end
28
31
 
29
32
  class Queue
30
33
 
@@ -1,3 +1,3 @@
1
1
  module Asynchronic
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
@@ -23,5 +23,12 @@ describe Asynchronic::QueueEngine::Synchronic do
23
23
  process = Asynchronic[pid]
24
24
  process.result.must_equal 20
25
25
  end
26
+
27
+ it 'Graph job' do
28
+ pid = GraphJob.enqueue input: 100
29
+ process = Asynchronic[pid]
30
+ process.must_be_completed
31
+ process.result.must_equal '10%' => 20, '20%' => 40
32
+ end
26
33
 
27
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asynchronic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-26 00:00:00.000000000 Z
11
+ date: 2017-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis