Skip to content

Instantly share code, notes, and snippets.

@toretore
Forked from mikecmpbll/act.rb
Last active August 29, 2015 14:18
Show Gist options
  • Save toretore/d4a2bc15d954765e1e66 to your computer and use it in GitHub Desktop.
Save toretore/d4a2bc15d954765e1e66 to your computer and use it in GitHub Desktop.
w_r, w_w = IO.pipe
t_r, t_w = IO.pipe
work = Thread.new { block.call; w_w.write('.') }
timeout = Thread.new{ sleep 10; t_w.write('.') }
io = IO.select [w_r, t_r]
if io == t_r
#Timeout
else
#No timeout
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment