mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
timeout.rb: watcher thread name
* lib/timeout.rb (Timeout#timeout): set watcher thread name to caller location for debugging. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
70bf86a711
commit
d660e06f28
1 changed files with 2 additions and 0 deletions
|
@ -73,11 +73,13 @@ module Timeout
|
||||||
def timeout(sec, klass = nil) #:yield: +sec+
|
def timeout(sec, klass = nil) #:yield: +sec+
|
||||||
return yield(sec) if sec == nil or sec.zero?
|
return yield(sec) if sec == nil or sec.zero?
|
||||||
message = "execution expired".freeze
|
message = "execution expired".freeze
|
||||||
|
from = "from #{caller_locations(1, 1)[0]}" if $DEBUG
|
||||||
e = Error
|
e = Error
|
||||||
bl = proc do |exception|
|
bl = proc do |exception|
|
||||||
begin
|
begin
|
||||||
x = Thread.current
|
x = Thread.current
|
||||||
y = Thread.start {
|
y = Thread.start {
|
||||||
|
Thread.current.name = from
|
||||||
begin
|
begin
|
||||||
sleep sec
|
sleep sec
|
||||||
rescue => e
|
rescue => e
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue