Skip to content

Commit 141e959

Browse files
committed
More generous pool termination timeouts
1 parent 64a22b0 commit 141e959

12 files changed

+69
-65
lines changed

spec/concurrent/agent_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ def update(time, old_value, new_value)
862862
expect(bucket).to eq [1, 2, 3]
863863

864864
executor.kill
865-
expect(executor.wait_for_termination(1)).to eq true
865+
expect(executor.wait_for_termination(pool_termination_timeout)).to eq true
866866
end
867867
end
868868

spec/concurrent/executor/cached_thread_pool_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Concurrent
1010

1111
after(:each) do
1212
subject.shutdown
13-
expect(subject.wait_for_termination(1)).to eq true
13+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
1414
end
1515

1616
it_should_behave_like :thread_pool
@@ -56,7 +56,7 @@ module Concurrent
5656
subject.post { latch.count_down }
5757
latch.wait(0.1)
5858
subject.shutdown
59-
expect(subject.wait_for_termination(1)).to eq true
59+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
6060
expect(subject.min_length).to eq 0
6161
end
6262
end
@@ -79,7 +79,7 @@ module Concurrent
7979
subject.post { latch.count_down }
8080
latch.wait(0.1)
8181
subject.shutdown
82-
expect(subject.wait_for_termination(1)).to eq true
82+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
8383
expect(subject.max_length).to eq described_class::DEFAULT_MAX_POOL_SIZE
8484
end
8585
end
@@ -102,7 +102,7 @@ module Concurrent
102102
subject.post { latch.count_down }
103103
latch.wait(0.1)
104104
subject.shutdown
105-
expect(subject.wait_for_termination(1)).to eq true
105+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
106106
expect(subject.largest_length).to be > 0
107107
end
108108
end
@@ -130,14 +130,14 @@ module Concurrent
130130
subject = CachedThreadPool.new(fallback_policy: :discard)
131131
expect(subject.fallback_policy).to eq :discard
132132
subject.shutdown
133-
expect(subject.wait_for_termination(1)).to eq true
133+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
134134
end
135135

136136
it 'defaults :fallback_policy to :abort' do
137137
subject = CachedThreadPool.new
138138
expect(subject.fallback_policy).to eq :abort
139139
subject.shutdown
140-
expect(subject.wait_for_termination(1)).to eq true
140+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
141141
end
142142

143143
it 'raises an exception if given an invalid :fallback_policy' do

spec/concurrent/executor/executor_service_shared.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
after(:each) do
66
subject.shutdown
7-
expect(subject.wait_for_termination(1)).to eq true
7+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
88
end
99

1010
it_should_behave_like :global_thread_pool
@@ -43,18 +43,18 @@
4343
subject.post{ sleep(0.5) }
4444
subject.shutdown
4545
expect(subject).not_to be_running
46-
expect(subject.wait_for_termination(1)).to eq true
46+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
4747
end
4848

4949
it 'returns false when the thread pool is shutdown' do
5050
subject.shutdown
51-
expect(subject.wait_for_termination(1)).to eq true
51+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
5252
expect(subject).not_to be_running
5353
end
5454

5555
it 'returns false when the thread pool is killed' do
5656
subject.kill
57-
expect(subject.wait_for_termination(1)).to eq true
57+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
5858
expect(subject).not_to be_running
5959
end
6060
end
@@ -67,7 +67,7 @@
6767
subject.post{ sleep(0.1); latch1.count_down }
6868
latch1.wait(1)
6969
subject.shutdown
70-
expect(subject.wait_for_termination(1)).to eq true
70+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
7171
begin
7272
subject.post{ latch2.count_down }
7373
rescue Concurrent::RejectedExecutionError
@@ -97,7 +97,7 @@
9797
latch = Concurrent::CountDownLatch.new(1)
9898
subject.post{ sleep(0.1); latch.count_down }
9999
subject.shutdown
100-
expect(subject.wait_for_termination(1)).to eq true
100+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
101101
expect(latch.wait(1)).to be_truthy
102102
end
103103

@@ -107,7 +107,7 @@
107107
subject.post { sleep 0.1; q << i }
108108
end
109109
subject.shutdown
110-
expect(subject.wait_for_termination(1)).to eq true
110+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
111111
expect(q.length).to eq 5
112112
end
113113

@@ -120,7 +120,7 @@
120120
subject.post{ expected.increment }
121121
rescue Concurrent::RejectedExecutionError
122122
end
123-
expect(subject.wait_for_termination(1)).to eq true
123+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
124124
expect(expected.value).to eq(2)
125125
end
126126
end
@@ -164,14 +164,14 @@
164164
10.times { subject << proc{ nil } }
165165
sleep(0.1)
166166
subject.shutdown
167-
expect(subject.wait_for_termination(1)).to be_truthy
167+
expect(subject.wait_for_termination(pool_termination_timeout)).to be_truthy
168168
end
169169

170170
it 'returns true when shutdown successfully completes before timeout' do
171171
subject.post{ sleep(0.5) }
172172
sleep(0.1)
173173
subject.shutdown
174-
expect(subject.wait_for_termination(1)).to be_truthy
174+
expect(subject.wait_for_termination(pool_termination_timeout)).to be_truthy
175175
end
176176

177177
it 'returns false when shutdown fails to complete before timeout' do

spec/concurrent/executor/fixed_thread_pool_spec.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Concurrent
99

1010
after(:each) do
1111
subject.shutdown
12-
expect(subject.wait_for_termination(1)).to eq true
12+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
1313
end
1414

1515
it_should_behave_like :thread_pool
@@ -56,21 +56,21 @@ module Concurrent
5656
subject = described_class.new(5, :max_queue => 10)
5757
expect(subject.max_queue).to eq 10
5858
subject.shutdown
59-
expect(subject.wait_for_termination(1)).to eq true
59+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
6060
end
6161

6262
it 'correctly sets valid :fallback_policy' do
6363
subject = described_class.new(5, :fallback_policy => :caller_runs)
6464
expect(subject.fallback_policy).to eq :caller_runs
6565
subject.shutdown
66-
expect(subject.wait_for_termination(1)).to eq true
66+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
6767
end
6868

6969
it "correctly sets valid :idletime" do
7070
subject = described_class.new(5, :idletime => 10)
7171
expect(subject.idletime).to eq 10
7272
subject.shutdown
73-
expect(subject.wait_for_termination(1)).to eq true
73+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
7474
end
7575

7676
it 'raises an exception if given an invalid :fallback_policy' do
@@ -98,7 +98,7 @@ module Concurrent
9898
subject.post { latch.count_down }
9999
latch.wait(0.1)
100100
subject.shutdown
101-
expect(subject.wait_for_termination(1)).to eq true
101+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
102102
expect(subject.min_length).to eq num_threads
103103
end
104104
end
@@ -121,7 +121,7 @@ module Concurrent
121121
subject.post { latch.count_down }
122122
latch.wait(0.1)
123123
subject.shutdown
124-
expect(subject.wait_for_termination(1)).to eq true
124+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
125125
expect(subject.max_length).to eq num_threads
126126
end
127127
end
@@ -154,7 +154,7 @@ module Concurrent
154154
subject.post { latch.count_down }
155155
latch.wait(0.1)
156156
subject.shutdown
157-
expect(subject.wait_for_termination(1)).to eq true
157+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
158158
expect(subject.largest_length).to eq num_threads
159159
end
160160
end
@@ -186,7 +186,7 @@ module Concurrent
186186
expect(pool.length).to eq 5
187187
latch.count_down
188188
pool.shutdown
189-
expect(pool.wait_for_termination(1)).to eq true
189+
expect(pool.wait_for_termination(pool_termination_timeout)).to eq true
190190
end
191191
end
192192

@@ -217,7 +217,7 @@ module Concurrent
217217
latch.wait(1)
218218
}.to raise_error(RejectedExecutionError)
219219
subject.shutdown
220-
expect(subject.wait_for_termination(1)).to eq true
220+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
221221
end
222222

223223
# On discard, we'd expect no error, but also not all five results
@@ -237,7 +237,7 @@ module Concurrent
237237

238238
expect(@queue.length).to be < 5
239239
subject.shutdown
240-
expect(subject.wait_for_termination(1)).to eq true
240+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
241241
end
242242

243243
# To check for caller_runs, we'll check how many unique threads
@@ -267,7 +267,7 @@ module Concurrent
267267
expect(a.uniq.size).to be_within(1).of(3) # one for each of the two threads, plus the caller
268268

269269
subject.shutdown
270-
expect(subject.wait_for_termination(1)).to eq true
270+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
271271
end
272272
end
273273

@@ -283,7 +283,7 @@ module Concurrent
283283
subject = FixedThreadPool.new(5, fallback_policy: :discard)
284284
expect(subject.fallback_policy).to eq :discard
285285
subject.shutdown
286-
expect(subject.wait_for_termination(1)).to eq true
286+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
287287
end
288288

289289
else
@@ -307,7 +307,7 @@ module Concurrent
307307
sleep(0.1)
308308
expect(pool.length).to eq 5
309309
pool.shutdown
310-
expect(pool.wait_for_termination(1)).to eq true
310+
expect(pool.wait_for_termination(pool_termination_timeout)).to eq true
311311
end
312312
end
313313
end

spec/concurrent/executor/java_single_thread_executor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Concurrent
88

99
after(:each) do
1010
subject.shutdown
11-
expect(subject.wait_for_termination(1)).to eq true
11+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
1212
end
1313

1414
subject { JavaSingleThreadExecutor.new }

spec/concurrent/executor/java_thread_pool_executor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Concurrent
88

99
after(:each) do
1010
subject.shutdown
11-
expect(subject.wait_for_termination(1)).to eq true
11+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
1212
end
1313

1414
subject do

spec/concurrent/executor/ruby_single_thread_executor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Concurrent
66

77
after(:each) do
88
subject.shutdown
9-
expect(subject.wait_for_termination(1)).to eq true
9+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
1010
end
1111

1212
subject { RubySingleThreadExecutor.new }

spec/concurrent/executor/ruby_thread_pool_executor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Concurrent
66

77
after(:each) do
88
subject.shutdown
9-
expect(subject.wait_for_termination(1)).to eq true
9+
expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
1010
end
1111

1212
subject do

0 commit comments

Comments
 (0)