4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/deferrer/runner.rb', line 4
def run(options = {})
loop_frequency = options.fetch(:loop_frequency, 0.1)
single_run = options.fetch(:single_run, false)
ignore_time = options.fetch(:ignore_time, false)
loop do
begin
while item = Deferrer::Queue.pop(ignore_time)
Processor.new(item).process
end
rescue StandardError => e
log(:error, "Error: #{e.class}: #{e.message}")
rescue Exception => e
log(:error, "Error: #{e.class}: #{e.message}")
raise
end
break if single_run
sleep loop_frequency
end
end
|