Skip to content

Commit

Permalink
Moved auto_terminate daemon test to executor_service_shared.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
fzakaria committed Feb 6, 2020
1 parent f2de94a commit 40bd29a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
22 changes: 0 additions & 22 deletions spec/concurrent/executor/cached_thread_pool_spec.rb
Expand Up @@ -201,28 +201,6 @@ module Concurrent
end
end

context 'auto terminate' do

# https://github.com/ruby-concurrency/concurrent-ruby/issues/817
# https://github.com/ruby-concurrency/concurrent-ruby/issues/839
it 'does not stop shutdown ' do
Timeout.timeout(10) do
begin
test_file = File.join File.dirname(__FILE__), 'pool_quits.rb'
pid = spawn RbConfig.ruby, test_file
Process.waitpid pid
expect($?.success?).to eq true
rescue Errno::ECHILD
# child already gone
rescue Timeout::Error => e
Process.kill :KILL, pid
raise e
end
end
end

end

context 'stress', notravis: true do
configurations = [
{ min_threads: 2,
Expand Down
Expand Up @@ -4,9 +4,11 @@

require 'concurrent-ruby'

pool = Concurrent::CachedThreadPool.new
pool.post do
sleep # sleep indefinitely
executors = [Concurrent::CachedThreadPool.new, Concurrent::SingleThreadExecutor.new, Concurrent::FixedThreadPool.new(1)]
executors.each do |executor|
executor.post do
sleep # sleep indefinitely
end
end

# the process main thread should quit out which should kill the daemon CachedThreadPool
22 changes: 22 additions & 0 deletions spec/concurrent/executor/executor_service_shared.rb
Expand Up @@ -33,6 +33,28 @@
end
end

context 'auto terminate' do

# https://github.com/ruby-concurrency/concurrent-ruby/issues/817
# https://github.com/ruby-concurrency/concurrent-ruby/issues/839
it 'does not stop shutdown ' do
Timeout.timeout(10) do
begin
test_file = File.join File.dirname(__FILE__), 'executor_quits.rb'
pid = spawn RbConfig.ruby, test_file
Process.waitpid pid
expect($?.success?).to eq true
rescue Errno::ECHILD
# child already gone
rescue Timeout::Error => e
Process.kill :KILL, pid
raise e
end
end
end

end

context '#running?' do

it 'returns true when the thread pool is running' do
Expand Down

0 comments on commit 40bd29a

Please sign in to comment.