Commit 97327dfd authored by Guillaume Seguin's avatar Guillaume Seguin

Harden get_eta against race conditions

get_eta could be called from statuschecker thread after self.p.printing
was set to True but before startcb was called in print thread, thus
leaving compute_eta uninitialized
parent 0308df47
...@@ -1499,10 +1499,12 @@ class pronsole(cmd.Cmd): ...@@ -1499,10 +1499,12 @@ class pronsole(cmd.Cmd):
secondsestimate = secondselapsed / max(fractioncomplete, 0.000001) secondsestimate = secondselapsed / max(fractioncomplete, 0.000001)
secondsremain = secondsestimate - secondselapsed secondsremain = secondsestimate - secondselapsed
progress = fractioncomplete progress = fractioncomplete
else: elif self.compute_eta is not None:
secondselapsed = int(time.time() - self.starttime + self.extra_print_time) secondselapsed = int(time.time() - self.starttime + self.extra_print_time)
secondsremain, secondsestimate = self.compute_eta(self.p.queueindex, secondselapsed) secondsremain, secondsestimate = self.compute_eta(self.p.queueindex, secondselapsed)
progress = self.p.queueindex progress = self.p.queueindex
else:
secondsremain, secondsestimate, progress = 1, 1, 0
return secondsremain, secondsestimate, progress return secondsremain, secondsestimate, progress
def do_eta(self, l): def do_eta(self, l):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment