1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Merge pull request #2036 from composerinteralia/threadpool-todos

Address thread pool test TODOs [changelog skip]
This commit is contained in:
Nate Berkopec 2019-10-17 16:19:40 +08:00 committed by GitHub
commit a51206514c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -223,27 +223,32 @@ class TestThreadPool < Minitest::Test
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
@ -252,7 +257,9 @@ class TestThreadPool < Minitest::Test
@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