lib/sidekiq/limit_fetch/redis.rb in sidekiq-limit_fetch-2.4.0 vs lib/sidekiq/limit_fetch/redis.rb in sidekiq-limit_fetch-2.4.1

- old
+ new

@@ -1,20 +1,25 @@ module Sidekiq::LimitFetch::Redis extend self - # prevent blocking of fetcher - # more bullet-proof and faster (O_O) - # than using Celluloid::IO - # - # https://github.com/brainopia/sidekiq-limit_fetch/issues/41 - # explanation of why Future#value is beneficial here def nonblocking_redis redis do |redis| - begin - Celluloid::Future.new { yield redis }.value + # Celluloid 0.16 broke this method + if Celluloid::VERSION.to_f >= 0.16 + yield redis + else + # prevent blocking of fetcher + # more bullet-proof and faster (O_O) + # than using Celluloid::IO + # + # https://github.com/brainopia/sidekiq-limit_fetch/issues/41 + # explanation of why Future#value is beneficial here + begin + Celluloid::Future.new { yield redis }.value + rescue Celluloid::Task::TerminatedError + end end end - rescue Celluloid::Task::TerminatedError end def redis Sidekiq.redis {|it| yield it } end