Search code examples
rubyscheduled-tasksrufus-scheduler

Rufus::Scheduler join can not exit at last in ruby


i use Rufus::Scheduler to schedule a task, the code is listed below:

class Scheduler
  def self.run
    scheduler = Rufus::Scheduler.start_new
    job = scheduler.in '5s', A.new
    scheduler.join
  end
  class A
    def call(job)
      puts "xxxxxx"
    end
  end
end
Scheduler.run

after running the code, it has print 'xxxx', but after running the call method, the join can not exit by itself and always hang-up.

is there some way to exit the join after waiting to finish the job? thank u.


Solution

  • Use plain Thread can reach the requirement.