Sha256: cde22061df9cefc4f84f32c9100fc924f1b01eba68e5fd0e0b548941bc269910
Contents?: true
Size: 896 Bytes
Versions: 4
Compression:
Stored size: 896 Bytes
Contents
module Sphinx begin # Try to use the SystemTimer gem instead of Ruby's timeout library # when running on something that looks like Ruby 1.8.x. See: # http://ph7spot.com/articles/system_timer # We don't want to bother trying to load SystemTimer on jruby and # ruby 1.9+ if defined?(JRUBY_VERSION) || (RUBY_VERSION >= '1.9') require 'timeout' Timeout = ::Timeout else require 'system_timer' Timeout = ::SystemTimer end rescue LoadError => e puts "[sphinx] Could not load SystemTimer gem, falling back to Ruby's slower/unsafe timeout library: #{e.message}" require 'timeout' Timeout = ::Timeout end # Executes specified block respecting timeout passed. # # @private def self.safe_execute(timeout = 5, &block) if timeout > 0 Sphinx::Timeout.timeout(timeout, &block) else yield end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
sphinx-0.9.9.2117 | lib/sphinx/timeout.rb |
sphinx-0.9.10.2122 | lib/sphinx/timeout.rb |
sphinx-0.9.10.2094 | lib/sphinx/timeout.rb |
sphinx-0.9.10.2091 | lib/sphinx/timeout.rb |