lib/ecoportal/api/v1/job/awaiter.rb in ecoportal-api-0.10.4 vs lib/ecoportal/api/v1/job/awaiter.rb in ecoportal-api-0.10.5
- old
+ new
@@ -6,11 +6,11 @@
include Common::Client::TimeOut
DELAY_STATUS_CHECK = 4
MIN_STATUS_CHECK = 2
- TIMEOUT_APPROACH = :conservative # adaptative timeout
+ TIMEOUT_APPROACH = :min # :conservative # adaptative timeout
TIMEOUT_FALLBACK = :min
attr_reader :job, :job_id, :total
attr_accessor :timeout_approach
@@ -37,15 +37,16 @@
before = Time.now
delay_status_check = nil
loop do
status = job.status(job_id)
+ done = status.progress
waited = Time.now - before
adapted = waited
adapted = waited - (delay_status_check / 2) if delay_status_check
- ratio = throughput!(adapted, count: status.progress)
+ ratio = throughput!(adapted, count: done)
break status if status.complete?(total)
pending = status.pending(total)
left = max_timeout - waited
@@ -55,10 +56,10 @@
delay_status_check = status_check_in(pending, timeout_in: left)
msg = " ... Awaiting #{delay_status_check} s. -- "
msg << " TimeOut: #{left.round(2)} s. "
msg << "(job '#{job_id}') "
- msg << "Done: #{status.progress} (est. #{ratio} rec/s) "
+ msg << "Done: #{done} (est. #{ratio} rec/s) "
msg << " \r"
print msg
$stdout.flush