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!
Project
terminator
an external timeout mechanism based on processes and signals
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
Development
Primary Language
Ruby
Licenses
same as ruby's
Dependencies
Runtime
>= 2.2
Project Readme