Reputation: 30182
I need to write a ruby block that will be polling remote network service. Since, it’s network love I need to enforce several conditions:
Is there an execution library or equivalent in ruby which I can use? I need to basically setup a thread to run in the background and block on it’s execution, then expect the status / return value of the thread (block) and act upon the result.
Being somewhat new to ruby //
Upvotes: 0
Views: 528
Reputation: 16506
Try something like this:
Timeout.timeout(60) do #time is sec
#your code
end
rescue Timeout::Error
#rescue code
end
Upvotes: 2