I would like to run a block for 60 seconds. What I have come up with thus far does not break out of the block as desired.
@start_time = Time.now
stream_some_data do |x|
# .. do something ...
break if Time.now == @start_time + 60
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since you’re unlikely to get to that line at exactly 60 seconds past the start, try: