Skip to content

Commit 40bd29a

Browse files
committed
Moved auto_terminate daemon test to executor_service_shared.rb
1 parent f2de94a commit 40bd29a

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

spec/concurrent/executor/cached_thread_pool_spec.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -201,28 +201,6 @@ module Concurrent
201201
end
202202
end
203203

204-
context 'auto terminate' do
205-
206-
# https://github.com/ruby-concurrency/concurrent-ruby/issues/817
207-
# https://github.com/ruby-concurrency/concurrent-ruby/issues/839
208-
it 'does not stop shutdown ' do
209-
Timeout.timeout(10) do
210-
begin
211-
test_file = File.join File.dirname(__FILE__), 'pool_quits.rb'
212-
pid = spawn RbConfig.ruby, test_file
213-
Process.waitpid pid
214-
expect($?.success?).to eq true
215-
rescue Errno::ECHILD
216-
# child already gone
217-
rescue Timeout::Error => e
218-
Process.kill :KILL, pid
219-
raise e
220-
end
221-
end
222-
end
223-
224-
end
225-
226204
context 'stress', notravis: true do
227205
configurations = [
228206
{ min_threads: 2,

spec/concurrent/executor/pool_quits.rb renamed to spec/concurrent/executor/executor_quits.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
require 'concurrent-ruby'
66

7-
pool = Concurrent::CachedThreadPool.new
8-
pool.post do
9-
sleep # sleep indefinitely
7+
executors = [Concurrent::CachedThreadPool.new, Concurrent::SingleThreadExecutor.new, Concurrent::FixedThreadPool.new(1)]
8+
executors.each do |executor|
9+
executor.post do
10+
sleep # sleep indefinitely
11+
end
1012
end
1113

1214
# the process main thread should quit out which should kill the daemon CachedThreadPool

spec/concurrent/executor/executor_service_shared.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,28 @@
3333
end
3434
end
3535

36+
context 'auto terminate' do
37+
38+
# https://github.com/ruby-concurrency/concurrent-ruby/issues/817
39+
# https://github.com/ruby-concurrency/concurrent-ruby/issues/839
40+
it 'does not stop shutdown ' do
41+
Timeout.timeout(10) do
42+
begin
43+
test_file = File.join File.dirname(__FILE__), 'executor_quits.rb'
44+
pid = spawn RbConfig.ruby, test_file
45+
Process.waitpid pid
46+
expect($?.success?).to eq true
47+
rescue Errno::ECHILD
48+
# child already gone
49+
rescue Timeout::Error => e
50+
Process.kill :KILL, pid
51+
raise e
52+
end
53+
end
54+
end
55+
56+
end
57+
3658
context '#running?' do
3759

3860
it 'returns true when the thread pool is running' do

0 commit comments

Comments
 (0)