Sha256: e656f8ccc98d0d0323ad1b5af8d42b5c24df83f965fdb1ea17f947c33d5b8226
Contents?: true
Size: 825 Bytes
Versions: 1
Compression:
Stored size: 825 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 def self.safe_execute(timeout = 5, &block) if timeout > 0 Sphinx::Timeout.timeout(timeout, &block) else yield end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sphinx-0.9.10.2043 | lib/sphinx/timeout.rb |