Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
an external timeout mechanism based on processes and signals
Ruby CSS
branch: master
Failed to load latest commit information.
doc die svn turds
lib
pkg first commit
samples
spec die svn turds
README
README.tmpl
Rakefile first commit
gen_readme.rb first commit
terminator.gemspec

README

NAME
  terminator

SYNOPSIS
  an external timeout mechanism based on processes and signals.  safe on
  windows.  safe for system calls.  safe for minors.

INSTALL
  gem install terminator

URIS
  http://codeforpeople.com/lib/ruby
  http://rubyforge.org/projects/codeforpeople

HISTORY
  1.0.0
    cleanup for 1.9

  0.4.2
    initial version with

AUTHORS
  ara.t.howard - ara.t.howard@gmail.com
  mikel lindsaar - raasdnil@gmail.com

SAMPLES

  <========< samples/a.rb >========>

  ~ > cat samples/a.rb

    require 'terminator'
    
    Terminator.terminate 2 do
      sleep 4
    end

  ~ > ruby samples/a.rb

    samples/a.rb:3:in `<main>': Timeout out after 2.0s (Terminator::Error)
    	from /Users/ahoward/git/ahoward/terminator/lib/terminator.rb:138:in `eval'
    	from /Users/ahoward/git/ahoward/terminator/lib/terminator.rb:138:in `block in terminate'
    	from /Users/ahoward/git/ahoward/terminator/lib/terminator.rb:140:in `call'
    	from /Users/ahoward/git/ahoward/terminator/lib/terminator.rb:140:in `block in terminate'
    	from samples/a.rb:4:in `call'
    	from samples/a.rb:4:in `sleep'
    	from samples/a.rb:4:in `block in <main>'
    	from /Users/ahoward/git/ahoward/terminator/lib/terminator.rb:147:in `call'
    	from /Users/ahoward/git/ahoward/terminator/lib/terminator.rb:147:in `terminate'
    	from samples/a.rb:3:in `<main>'


  <========< samples/b.rb >========>

  ~ > cat samples/b.rb

    require 'terminator'
    
    Terminator.terminate 0.2 do
      sleep 0.4 rescue puts 'timed out!'
    end

  ~ > ruby samples/b.rb

    timed out!


  <========< samples/c.rb >========>

  ~ > cat samples/c.rb

    require 'terminator'
    
    begin
      Terminator.terminate :seconds => 0.2 do
        sleep 0.4
      end
    rescue Terminator.error
      puts 'timed out!'
    end

  ~ > ruby samples/c.rb

    timed out!


  <========< samples/d.rb >========>

  ~ > cat samples/d.rb

    require 'terminator'
    
    trap = lambda{ puts "signaled @ #{ Time.now.to_i }" }
    
    Terminator.terminate :seconds => 1, :trap => trap do
      sleep 2
      puts "woke up  @ #{ Time.now.to_i }"
    end

  ~ > ruby samples/d.rb

    signaled @ 1376702768
    woke up  @ 1376702769


  <========< samples/e.rb >========>

  ~ > cat samples/e.rb

    require 'terminator'
    
    puts "Looping 1000 times on the terminator..."
    success = false
    1.upto(1000) do |i|
      success = false
      Terminator.terminate(1) do
        success = true
      end
    end
    puts "\nsuccess!" if success

  ~ > ruby samples/e.rb

    Looping 1000 times on the terminator...
    
    success!

Something went wrong with that request. Please try again.