parallizer 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/lib/parallizer.rb +4 -0
- data/lib/parallizer/version.rb +1 -1
- data/lib/parallizer/worker.rb +5 -1
- data/spec/parallizer_spec.rb +26 -0
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/parallizer.rb
CHANGED
data/lib/parallizer/version.rb
CHANGED
data/lib/parallizer/worker.rb
CHANGED
@@ -7,14 +7,18 @@ class Parallizer
|
|
7
7
|
|
8
8
|
(options[:retries] + 1).times do
|
9
9
|
begin
|
10
|
+
Thread.current[:parallizer_thread] = true
|
11
|
+
|
10
12
|
result[:exception] = nil # reset exception before each send attempt
|
11
13
|
result[:result] = client.send(method_name, *args)
|
12
14
|
break # success
|
13
15
|
rescue Exception => e
|
14
16
|
result[:exception] = e
|
17
|
+
ensure
|
18
|
+
Thread.current[:parallizer_thread] = nil
|
15
19
|
end
|
16
20
|
end
|
17
|
-
|
21
|
+
|
18
22
|
result
|
19
23
|
end
|
20
24
|
end
|
data/spec/parallizer_spec.rb
CHANGED
@@ -18,6 +18,10 @@ describe Parallizer do
|
|
18
18
|
def another_current_thread
|
19
19
|
Thread.current
|
20
20
|
end
|
21
|
+
|
22
|
+
def in_parallizer_thread?
|
23
|
+
Parallizer.in_parallizer_thread?
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
class AnotherTestObject
|
@@ -30,6 +34,28 @@ describe Parallizer do
|
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
37
|
+
describe "#in_parallizer_thread?" do
|
38
|
+
before do
|
39
|
+
@client = TestObject.new
|
40
|
+
@parallizer = Parallizer.new(@client)
|
41
|
+
end
|
42
|
+
|
43
|
+
subject do
|
44
|
+
parallizer = Parallizer.new(@client)
|
45
|
+
parallizer.add.in_parallizer_thread?
|
46
|
+
proxy = parallizer.create_proxy
|
47
|
+
proxy.in_parallizer_thread?
|
48
|
+
end
|
49
|
+
|
50
|
+
it "is not in_parallizer_thread on the client" do
|
51
|
+
@client.in_parallizer_thread?.should be_false
|
52
|
+
end
|
53
|
+
|
54
|
+
it "is in_parallizer_thread after parallizing" do
|
55
|
+
subject.should be_true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
33
59
|
describe "#add" do
|
34
60
|
before do
|
35
61
|
@client = TestObject.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: celluloid
|