Add timeout

Some details http://www.ruby-forum.com/topic/1697092