diff options
author | Tim Emiola <temiola@google.com> | 2015-06-11 09:35:06 -0700 |
---|---|---|
committer | Tim Emiola <temiola@google.com> | 2015-06-17 06:22:11 -0700 |
commit | b1fa5d46275572274fe3e5a501c267be4ea9ffe8 (patch) | |
tree | e482011cc310ca31c196061815aae926ecb1be8d /src/ruby/lib | |
parent | 48dd6bfb53ff9ddda39b9b2e6ced297e95027514 (diff) |
Ruby shutdown api migration
+ all tests pass,
- but there are a couple of workarounds
- tests are flaky
Diffstat (limited to 'src/ruby/lib')
-rw-r--r-- | src/ruby/lib/grpc/generic/rpc_server.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb index dcb11bfbef..a7e20d6b82 100644 --- a/src/ruby/lib/grpc/generic/rpc_server.rb +++ b/src/ruby/lib/grpc/generic/rpc_server.rb @@ -278,7 +278,9 @@ module GRPC @stopped = true end @pool.stop - @server.close + deadline = from_relative_time(@poll_period) + + @server.close(@cq, deadline) end # determines if the server has been stopped @@ -410,17 +412,18 @@ module GRPC # handles calls to the server def loop_handle_server_calls fail 'not running' unless @running - request_call_tag = Object.new + loop_tag = Object.new until stopped? deadline = from_relative_time(@poll_period) begin - an_rpc = @server.request_call(@cq, request_call_tag, deadline) + an_rpc = @server.request_call(@cq, loop_tag, deadline) + c = new_active_server_call(an_rpc) rescue Core::CallError, RuntimeError => e - # can happen during server shutdown + # these might happen for various reasonse. The correct behaviour of + # the server is to log them and continue. GRPC.logger.warn("server call failed: #{e}") next end - c = new_active_server_call(an_rpc) unless c.nil? mth = an_rpc.method.to_sym @pool.schedule(c) do |call| |