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

Set worker thread name.

Supports multithreaded logging and problem diagnosis.
This commit is contained in:
Reid Morrison 2016-04-28 10:28:44 -04:00
parent 41c771b264
commit 452feb791b
2 changed files with 6 additions and 0 deletions

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