【发布时间】:2014-10-03 21:25:27
【问题描述】:
我有一些代码可能会运行更长的时间。但是,如果它确实我想杀死它,这就是我现在正在做的事情:
def perform
Timeout.timeout(ENV['JOB_TIMEOUT'].to_i, Exceptions::WorkerTimeout) { do_perform }
end
私人的 def do_perform ...一些代码... 结束
其中JOB_TIMEOUT 是一个环境变量,其值为10.seconds。我收到报告称,这仍然不能阻止我的工作运行时间超过应有的时间。
有没有更好的方法来做到这一点?
【问题讨论】:
标签: ruby-on-rails ruby delayed-job