lib/fanforce/worker/runner.rb in fanforce-worker-0.17.2 vs lib/fanforce/worker/runner.rb in fanforce-worker-0.18.0
- old
+ new
@@ -10,12 +10,10 @@
def initialize(worker_data, min_execution_time=300, &code_block)
raise "min_execution_time was set to #{min_execution_time}, which is #{min_execution_time - MAX_EXECUTION_TIME} seconds too long" if min_execution_time > MAX_EXECUTION_TIME
log.debug 'LOADING WORKER ENV'
- @worker_started_at = Time.now
-
@queue_id = worker_data['queue_id'] || (raise 'worker_data must contain queue_id')
@worker_env = worker_data['env_vars'] || {}
@min_execution_time = min_execution_time
@code_block = code_block
@@ -85,15 +83,15 @@
log.debug 'REMOVED JOB FROM QUEUE, AND SAVING TO ERROR CACHE...'
Fanforce::Worker::Errors.add(@queue_id, e, job_data, @worker_env)
end
def worker_time_remaining
- time_since_load = Time.now - @worker_started_at
+ time_since_load = Time.now - Fanforce::Worker::LOADED_AT
MAX_EXECUTION_TIME - time_since_load
end
def job_has_enough_time_to_run
- time_since_load = Time.now - @worker_started_at
+ time_since_load = Time.now - Fanforce::Worker::LOADED_AT
return false if time_since_load > MAX_EXECUTION_TIME
return false if worker_time_remaining < @min_execution_time
return true
end
\ No newline at end of file