工人工作阻止了resque

时间:2013-03-22 10:53:50

标签: ruby redis resque

我正在使用redis pub / sub with resque worker,resque在第一份工作后挂起, 我的工人任务是阻止自然。我的理解是resque为每个新工作分配一个新线程。

我的工人如下

class SendInvitation
  @queue = :outbound_dialer
  def self.perform(contact_type, contact_no, invitation_audio_file)
    @invitationManager = DRbObject.new_with_uri(DRB_SERVER_URL)

    task_id = @invitationManager.send_invitation(contact_type, contact_no, invitation_audio_file)
    puts task_id+"is the currents task id"
    $redis = Redis.new(:timeout=>REDIS_TIMEOUT)
    $redis.subscribe('outbound_dialer') do |on|
      on.message do |channel, msg|
        data = JSON.parse(msg)
        if(data['id'] == task_id)
          puts 'here'
          @invitationManager = nil
          # exit
        end
      end
    end
  end
end

ps -ef结果

这里线程5784阻止resque任务,一旦我终止当前处理任务,resque开始下一个任务,并再次开始等待完成后 根3595 1 0 14:14? 00:00:34 /usr/bin/ruby1.9.1 / usr / local / bin / resque-web root 5370 1887 0 15:40 pts / 1 00:00:04 resque-2.0.0.pre.1:Forked 5784 at 1363947580 root 5784 5370 0 15:49 pts / 1 00:00:00 resque-2.0.0.pre.1:处理outbound_dialer自1363947580 [SendInvitation] root 5803 2140 0 15:49 pts / 2 00:00:00 grep --color = auto resque

我已经尝试过COUNT = 5

1 个答案:

答案 0 :(得分:0)

Resque确实为作业分配了一个新进程(而不是线程)。然后它等待工人完成并抓住下一份工作。如果您想要并行运行更多作业 - 运行更多resque工作进程。

相关问题