mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
timeout.rb: same object across fiber
* lib/timeout.rb (Timeout::ExitException.catch): do not freeze the exception for tag, so that the same object can be passed to the target fiber without duplication to attach backtrace at raise. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0884d0b944
commit
1133596e6b
1 changed files with 1 additions and 2 deletions
|
@ -31,17 +31,16 @@ module Timeout
|
|||
def self.catch(*args)
|
||||
exc = new(*args)
|
||||
exc.instance_variable_set(:@thread, Thread.current)
|
||||
exc.freeze
|
||||
::Kernel.catch(exc) {yield exc}
|
||||
end
|
||||
|
||||
def exception(*)
|
||||
# TODO: use Fiber.current to see if self can be thrown
|
||||
if self.thread == Thread.current
|
||||
bt = caller
|
||||
begin
|
||||
throw(self, bt)
|
||||
rescue UncaughtThrowError
|
||||
raise Error, message, backtrace
|
||||
end
|
||||
end
|
||||
self
|
||||
|
|
Loading…
Add table
Reference in a new issue