diff options
author | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-28 11:28:58 +0000 |
---|---|---|
committer | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-28 11:28:58 +0000 |
commit | 018f081233944ab97b4d7accf6c04ce386681f8e (patch) | |
tree | dbe35c5ac4ab7ab45faa4f6e04657df7d66e86ea /lib | |
parent | 4d9f5482aea747e614a8d78b5e8ec114b023a768 (diff) | |
download | ruby-018f081233944ab97b4d7accf6c04ce386681f8e.tar.gz |
* lib/drb/drb.rb (error_print): Add verbose failure messages and
avoid infamous DRb::DRbConnError. [Feature #12101]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/drb/drb.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb index 8011660156..d04ab3564d 100644 --- a/lib/drb/drb.rb +++ b/lib/drb/drb.rb @@ -1632,6 +1632,17 @@ module DRb include InvokeMethod18Mixin end + def error_print(exception) + exception.backtrace.inject(true) do |first, x| + if first + $stderr.puts "#{x}: #{exception} (#{exception.class})" + else + $stderr.puts "\tfrom #{x}" + end + false + end + end + # The main loop performed by a DRbServer's internal thread. # # Accepts a connection from a client, and starts up its own @@ -1655,13 +1666,10 @@ module DRb succ = false invoke_method = InvokeMethod.new(self, client) succ, result = invoke_method.perform - if !succ && verbose - p result - result.backtrace.each do |x| - puts x - end - end - client.send_reply(succ, result) rescue nil + error_print(result) if !succ && verbose + client.send_reply(succ, result) + rescue Exception => e + error_print(e) if verbose ensure client.close unless succ if Thread.current['DRb']['stop_service'] |