设定延迟工作的睡眠时间 [英] Setting sleep time in delayed job
问题描述
好,一个简单的问题。我想为延迟的上班族改变睡眠时间。在当前版本中我该怎么做?
Ok,a simple question. I want to change sleep time for my delayed job worker. How do I do it in the current version?
我为此找到了两个建议:
I've found out two suggestions for this:
Delayed :: Worker.const_set( SLEEP,sleep_time_in_seconds)
和
Delayed :: Worker.sleep_delay = sleep_time_in_seconds
。
两者之间有什么区别?
谢谢
推荐答案
这取决于您所使用的delay_job版本正在使用。如果您使用的是 tobi
版本( https:// github。 com / tobi / delayed_job ),请设置常量:
It depends on what version of delayed_job you are using. If you are using the tobi
version (https://github.com/tobi/delayed_job) you should set the constant:
Delayed::Worker.const_set('SLEEP', sleep_time_in_seconds)
如果您不知道所使用的版本,则 tobi
版本最有可能(您可以在插件目录中检查 delayed_job.gemspec
文件进行确认;它的内容类似于 s.homepage =< git-page-of-your-version>
)。
If you don't know what version you are using, the tobi
version is most likely it (you can check the delayed_job.gemspec
file in your plugin directory to confirm; it will have something like s.homepage = <git-page-of-your-version>
).
如果您使用的是 collectiveidea
版本( https://github.com/collectiveidea/delayed_job ),您应该使用属性设置器:
If you are using the collectiveidea
version (https://github.com/collectiveidea/delayed_job) you should use the attribute setter:
Delayed::Worker.sleep_delay = sleep_time_in_seconds
如果您使用的是其他版本,请查阅 README
rsion。
If you are using another version, consult the README
for that version.
这篇关于设定延迟工作的睡眠时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!