Refactoring: Make Scheduler more robust against job deletion while processing.
This commit is contained in:
parent
1be60c91db
commit
b5a44ee0d0
1 changed files with 13 additions and 6 deletions
|
@ -257,13 +257,20 @@ class Scheduler < ApplicationModel
|
|||
else
|
||||
_start_job(job)
|
||||
end
|
||||
job.pid = ''
|
||||
job.save
|
||||
logger.info " ...stopped thread for '#{job.method}'"
|
||||
ActiveRecord::Base.connection.close
|
||||
|
||||
# release thread lock and remove thread handle
|
||||
@@jobs_started.delete(job.id)
|
||||
if job.present?
|
||||
job.pid = ''
|
||||
job.save
|
||||
|
||||
logger.info " ...stopped thread for '#{job.method}'"
|
||||
|
||||
# release thread lock and remove thread handle
|
||||
@@jobs_started.delete(job.id)
|
||||
else
|
||||
logger.warn ' ...Job got deleted while running'
|
||||
end
|
||||
|
||||
ActiveRecord::Base.connection.close
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue