class Cloudtasker::UniqueJob::Lock::WhileExecuting

Conflict if any other job with the same args is moved to execution while the first job is executing.

Public Instance Methods

execute() { || ... } click to toggle source

Acquire a lock for the job and trigger a conflict if the lock could not be acquired.

# File lib/cloudtasker/unique_job/lock/while_executing.rb, line 13
def execute
  job.lock!
  yield
rescue LockError
  conflict_instance.on_execute { yield }
ensure
  # Unlock the job on any error to avoid deadlocks.
  job.unlock!
end