lib/rufus/scheduler.rb in rufus-scheduler-3.8.1 vs lib/rufus/scheduler.rb in rufus-scheduler-3.8.2

- old
+ new

@@ -7,11 +7,11 @@ module Rufus; end class Rufus::Scheduler - VERSION = '3.8.1' + VERSION = '3.8.2' EoTime = ::EtOrbi::EoTime require 'rufus/scheduler/util' require 'rufus/scheduler/jobs_core' @@ -441,14 +441,18 @@ pre = err.object_id.to_s ms = {}; mutexes.each { |k, v| ms[k] = v.locked? } stderr.puts("{ #{pre} rufus-scheduler intercepted an error:") - stderr.puts(" #{pre} job:") - stderr.puts(" #{pre} #{job.class} #{job.original.inspect} #{job.opts.inspect}") - stderr.puts(" #{pre} #{job.source_location.inspect}") - # TODO: eventually use a Job#detail or something like that + if job + stderr.puts(" #{pre} job:") + stderr.puts(" #{pre} #{job.class} #{job.original.inspect} #{job.opts.inspect}") + stderr.puts(" #{pre} #{job.source_location.inspect}") + # TODO: eventually use a Job#detail or something like that + else + stderr.puts(" #{pre} job: (error did not occur in a job)") + end stderr.puts(" #{pre} error:") stderr.puts(" #{pre} #{err.object_id}") stderr.puts(" #{pre} #{err.class}") stderr.puts(" #{pre} #{err}") err.backtrace.each do |l| @@ -528,11 +532,11 @@ @work_queue.clear unlock - @thread.join + @thread.join unless @thread == Thread.current end alias stop shutdown protected @@ -628,15 +632,23 @@ @thread = Thread.new do while @started_at do + begin - unschedule_jobs - trigger_jobs unless @paused_at - timeout_jobs + unschedule_jobs + trigger_jobs unless @paused_at + timeout_jobs - sleep(@frequency) + sleep(@frequency) + + rescue => err + # + # for `blocking: true` jobs mostly + # + on_error(nil, err) + end end rejoin end