FIX: Exception has to be wrapped in the connection as well.

This commit is contained in:
Guo Xiang Tan 2017-10-11 17:19:26 +08:00
parent 09721090a3
commit 36f8697a59
1 changed files with 5 additions and 8 deletions

View File

@ -63,17 +63,14 @@ module Scheduler
# using non_block to match Ruby #deq
def do_work(non_block = false)
db, job, desc = @queue.deq(non_block)
db ||= RailsMultisite::ConnectionManagement::DEFAULT
begin
if db
RailsMultisite::ConnectionManagement.with_connection(db: db) do
job.call
end
else
RailsMultisite::ConnectionManagement.with_connection(db: db) do
begin
job.call
rescue => ex
Discourse.handle_job_exception(ex, message: "Running deferred code '#{desc}'")
end
rescue => ex
Discourse.handle_job_exception(ex, message: "Running deferred code '#{desc}'")
end
rescue => ex
Discourse.handle_job_exception(ex, message: "Processing deferred code queue")