asynchronic 1.6.0 → 1.6.1

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: 7e70899d480cd9a9c3a99bf747e93a2e62e9c55b
4
- data.tar.gz: 41078d0bf32c17cf370d5eb3451dbbf66663fca5
3
+ metadata.gz: d7fb4fd2b230671121e3549ba81e3c1992fdd1a1
4
+ data.tar.gz: fcf4f6568ada9b633b9c79df8e4454341eddfeb0
5
5
  SHA512:
6
- metadata.gz: 857050561908c34ac116d4374ede47e22822244236cb3086e64579282360e7cdd017d8f2254f72bd0b2f7e25b51d65b78c00a78d1a794e5d7ac9fc075d99a01c
7
- data.tar.gz: f9d0618a300f6623402828ee739484bf07959e47cb2ad2ff5f5f41678b49fa1c6b250dc6ba0eb9acf9eae32b728e223626b6ef259eefa3322ae8ab630a52e5b8
6
+ metadata.gz: 9c52c72ca2da582331203903c69b2943537e4cad741eb9f1271e08c14310433c636c66d459347f45bf6f8ca2f4b96f41a76fa9d6bcbad12036da8e1c1bc58355
7
+ data.tar.gz: 658d807dfbc86c9751a13b0d50dbfbec2758c190108ab6e0fc084bf0c3a31420b91aff1aff33907a740ea8c25c03076322f4fb04ccaf71439bfe216b90d513d6
@@ -136,7 +136,7 @@ module Asynchronic
136
136
  end
137
137
 
138
138
  def get(key)
139
- data[key]
139
+ self.data[key]
140
140
  end
141
141
 
142
142
  def set(key, value)
@@ -192,8 +192,13 @@ module Asynchronic
192
192
 
193
193
  STATUSES.each do |status|
194
194
  define_method "#{status}!" do
195
- job.before_finalize if [:completed, :aborted].include?(status) && job.respond_to?(:before_finalize)
196
- self.status = status
195
+ begin
196
+ job.before_finalize if [:completed, :aborted].include?(status) && job.respond_to?(:before_finalize)
197
+ self.status = status
198
+ rescue Exception => exception
199
+ self.error = Error.new exception
200
+ self.status = :aborted
201
+ end
197
202
  end
198
203
  end
199
204
 
@@ -1,3 +1,3 @@
1
1
  module Asynchronic
2
- VERSION = '1.6.0'
2
+ VERSION = '1.6.1'
3
3
  end
data/spec/jobs.rb CHANGED
@@ -383,3 +383,15 @@ class BeforeFinalizeAbortedJob < Asynchronic::Job
383
383
  set :key, get(:key) + 1
384
384
  end
385
385
  end
386
+
387
+ class BeforeFinalizeRaisesExceptionJob < Asynchronic::Job
388
+
389
+ def call
390
+ nil
391
+ end
392
+
393
+ def before_finalize
394
+ raise 'Before finalize exception'
395
+ end
396
+
397
+ end
@@ -690,4 +690,22 @@ module LifeCycleExamples
690
690
  queue.must_be_empty
691
691
  end
692
692
 
693
+ it 'Before finalize raises exception and aborts' do
694
+ process = create BeforeFinalizeRaisesExceptionJob
695
+
696
+ process.must_be_initialized
697
+ queue.must_be_empty
698
+
699
+ process.enqueue
700
+
701
+ process.must_be_queued
702
+ queue.must_enqueued process
703
+
704
+ execute queue
705
+
706
+ process.must_be_aborted
707
+ process.real_error.must_equal 'Before finalize exception'
708
+ queue.must_be_empty
709
+ end
710
+
693
711
  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.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-22 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis