Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address thread pool test TODOs [changelog skip] #2036

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions test/test_thread_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,32 @@ def test_reap_only_dead_threads
def test_auto_reap_dead_threads
pool = new_pool(2,2) { Thread.current.kill }

pool.auto_reap! 0.1

pause

assert_equal 2, pool.spawned

# TODO: is there a point to these two lines?
pool << 1
pool << 2

pool.auto_reap! 0.1

pause

assert_equal 0, pool.spawned
end

def test_force_shutdown_immediately
finish = false
rescued = false

pool = new_pool(0, 1) do |work|
begin
@work_mutex.synchronize do
@work_done.signal
end
sleep 10 # TODO: do something here other than sleep
Thread.pass until finish
rescue Puma::ThreadPool::ForceShutdown
rescued = true
end
end

Expand All @@ -252,7 +257,9 @@ def test_force_shutdown_immediately
@work_mutex.synchronize do
@work_done.wait(@work_mutex, 5)
pool.shutdown(0)
finish = true
assert_equal 0, pool.spawned
assert rescued
end
end
end