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

Merge pull request #974 from rocketjob/feature/name_threads

Set worker thread name.
This commit is contained in:
Evan Phoenix 2016-05-09 18:51:56 -07:00
commit 3a0afd9175
3 changed files with 6 additions and 1 deletions

View file

@ -8,7 +8,6 @@ Rakefile
bin/puma
bin/puma-wild
bin/pumactl
docs/config.md
docs/nginx.md
docs/signals.md
docs/systemd.md

View file

@ -68,6 +68,8 @@ module Puma
@spawned += 1
th = Thread.new do
# Thread name is new in Ruby 2.3
Thread.current.name = 'puma %03i' % @spawned if Thread.current.respond_to?(:name=)
todo = @todo
block = @block
mutex = @mutex

View file

@ -19,9 +19,11 @@ class TestThreadPool < Test::Unit::TestCase
def test_append_spawns
saw = []
thread_name = nil
pool = new_pool(0, 1) do |work|
saw << work
thread_name = Thread.current.name if Thread.current.respond_to?(:name)
end
pool << 1
@ -30,6 +32,8 @@ class TestThreadPool < Test::Unit::TestCase
assert_equal [1], saw
assert_equal 1, pool.spawned
# Thread name is new in Ruby 2.3
assert_equal('puma 001', thread_name) if Thread.current.respond_to?(:name)
end
def test_converts_pool_sizes