Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Created April 9, 2015 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikecmpbll/2b419d6f5b6370109e16 to your computer and use it in GitHub Desktop.
Save mikecmpbll/2b419d6f5b6370109e16 to your computer and use it in GitHub Desktop.
def act(&block)
timeout = Time.now + 10
work = Thread.new { block.call }
while Time.now < timeout && work.alive? do
sleep(0.1)
end
if work.alive?
puts "hit timeout"
else
puts "no timeout"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment