[英]in ruby on rails how can I queu the job one by one?
I have a big problem, I try to queu job one by one in a queu in ruby on rails.我有一个大问题,我尝试在轨道上 ruby 的队列中一个一个地排队工作。 I really need that the controller dont access at the same time to a liste of function because it is a long process and it use the databases during.我真的需要 controller 不要同时访问 function 的列表,因为这是一个漫长的过程,并且在此期间会使用数据库。 If two time the process is started at same time (or little differences) it will be conflict in my data.如果两次同时启动该过程(或差异很小),我的数据将发生冲突。
Thanks for your help,谢谢你的帮助,
Pierre皮埃尔
the most easy why is to put a static attribute in class最简单的原因是将 static 属性放入 class
class MyJob
@@locked=0
def perform(*args)
while @@locked==1 do
sleep(0.2)
end
@@locked=1
# your code here
@@locked=0
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.