YUKI Hiroshi
null+****@clear*****
Tue Apr 14 20:09:15 JST 2015
YUKI Hiroshi 2015-04-14 20:09:15 +0900 (Tue, 14 Apr 2015) New Revision: d7b9c4f6736cc32407e11f85cdda6fff56ab5da2 https://github.com/droonga/droonga-client-ruby/commit/d7b9c4f6736cc32407e11f85cdda6fff56ab5da2 Message: Do timeout correctly for subscriptions with Thread Modified files: lib/droonga/client/connection/droonga-protocol/thread.rb Modified: lib/droonga/client/connection/droonga-protocol/thread.rb (+10 -0) =================================================================== --- lib/droonga/client/connection/droonga-protocol/thread.rb 2015-04-14 19:59:27 +0900 (1ef6dbd) +++ lib/droonga/client/connection/droonga-protocol/thread.rb 2015-04-14 20:09:15 +0900 (1b7703a) @@ -81,6 +81,7 @@ module Droonga receive_options = { :timeout => options[:timeout_seconds], } + start = Time.new sync = block.nil? if sync Enumerator.new do |yielder| @@ -88,13 +89,22 @@ module Droonga receiver.receive(receive_options) do |object| yielder << object end + if receive_options[:timeout] and + Time.new - start > receive_options[:timeout] + break + end end + receiver.close end else thread = ::Thread.new do begin loop do receiver.receive(receive_options, &block) + if receive_options[:timeout] and + Time.new - start > receive_options[:timeout] + break + end end ensure receiver.close -------------- next part -------------- HTML����������������������������...Télécharger