是否可以重置 Rails 中延迟作业的超时?
我有一项延迟的工作,需要运行几个步骤。我想在步骤完成时重置超时。
是否可以?
例如
# config/initializers/delayed_job_config.rb
Delayed::Worker.max_run_time = 5.minutes
# app/jobs/my_process_job.rb
class MyProcessJob < ApplicationJob
def perform
`sleep 4m` # step 1
# reset timeout
`sleep 4m` # step 2
puts 'done'
end
end
I have a delayed job that run a few steps. I would like to reset the timeout whenever a step is completed.
Is it possible?
For example
# config/initializers/delayed_job_config.rb
Delayed::Worker.max_run_time = 5.minutes
# app/jobs/my_process_job.rb
class MyProcessJob < ApplicationJob
def perform
`sleep 4m` # step 1
# reset timeout
`sleep 4m` # step 2
puts 'done'
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
了解延迟作业,不修改是无法重置超时的延迟工作。但是,您可以执行以下操作
Looking at how timeouts are implemented in Delayed Job, it's not possible to reset the timeout without modifying Delayed Job. However, you could do the following instead