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
|
else
|
||||||
_start_job(job)
|
_start_job(job)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if job.present?
|
||||||
job.pid = ''
|
job.pid = ''
|
||||||
job.save
|
job.save
|
||||||
|
|
||||||
logger.info " ...stopped thread for '#{job.method}'"
|
logger.info " ...stopped thread for '#{job.method}'"
|
||||||
ActiveRecord::Base.connection.close
|
|
||||||
|
|
||||||
# release thread lock and remove thread handle
|
# release thread lock and remove thread handle
|
||||||
@@jobs_started.delete(job.id)
|
@@jobs_started.delete(job.id)
|
||||||
|
else
|
||||||
|
logger.warn ' ...Job got deleted while running'
|
||||||
|
end
|
||||||
|
|
||||||
|
ActiveRecord::Base.connection.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue