moved the calc. of the progress bar pos. into a separate class

This commit is contained in:
2020-07-01 11:27:28 +02:00
parent 6121c7f408
commit 506222bcb8
+14 -3
View File
@@ -36,14 +36,14 @@ class BrokerClient:
self.running = True
with tqdm(total=n_pulses) as pbar:
with stqdm(total=n_pulses) as pbar:
while self.running:
current_pulseid = get_current_pulseid()
if current_pulseid > stop_pulseid:
break
sleep(self.wait_time)
delta_n = 1 + ((current_pulseid - start_pulseid) // rate_multiplicator) - pbar.n # +1 to start at 0 (otherwise starts at -1)
pbar.update(delta_n)
delta_n = (current_pulseid - start_pulseid) // rate_multiplicator
pbar.set(delta_n)
self.running = False
@@ -170,3 +170,14 @@ def aligned_pids(start, n, rm):
class stqdm(tqdm):
def set(self, elapsed):
"""
update with elapsed n, i.e., the delta between start and current n
"""
increment = elapsed + 1 - self.n # +1 to start at 0 (otherwise starts at -1)
self.update(increment)