Skip to content

Commit

Permalink
Fix progress bar flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
berkayurun committed Sep 4, 2023
1 parent f08dbaf commit e9ab542
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 5 additions & 7 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@

stop_signal_received = False


def signal_handler(signum, frame):
global stop_signal_received
stop_signal_received = True


def register_signal_handlers(clogger, queue_output, p_logger):
signal.signal(
signal.SIGTERM,
Expand Down Expand Up @@ -691,13 +693,12 @@ def controller(
# Handlers are used for a graceful exit, in case of a signal
register_signal_handlers(clogger, queue_output, p_logger)

pbar = tqdm(
total=len(faultlist), desc="Simulating faults", disable=not len(faultlist)
)
itter = 0
while 1:
if stop_signal_received:
clogger.info("Stopping the execution")
clogger.info(
"Stop signal received, finishing the current write operation..."
)
queue_output.put({"index": -4})

for p in p_list:
Expand Down Expand Up @@ -775,8 +776,6 @@ def controller(
# Find finished processes
p["process"].join(timeout=0)
if p["process"].is_alive() is False:
# Update the progress bar
pbar.update(1)
# Recalculate moving average
p_time_list.append(current_time - p["start_time"])
len_p_time_list = len(p_time_list)
Expand All @@ -789,7 +788,6 @@ def controller(
break

clogger.debug("{} experiments remaining in queue".format(queue_output.qsize()))
pbar.close()
p_logger.join()

clogger.debug("Done with qemu and logger")
Expand Down
3 changes: 3 additions & 0 deletions hdf5logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ def hdf5collector(
):
n._f_remove(recursive=True)

pbar = tqdm(total=num_exp, desc="Simulating faults", disable=not num_exp)
while num_exp > 0 or log_goldenrun or log_pregoldenrun or log_config:
# readout queue and get next output from qemu. Will block
exp = queue_output.get()
Expand All @@ -525,6 +526,7 @@ def hdf5collector(
)
)
num_exp = num_exp - 1
pbar.update(1)
elif exp["index"] == -2 and log_pregoldenrun:
if "Pregoldenrun" in f.root:
raise ValueError("Pregoldenrun already exists!")
Expand Down Expand Up @@ -581,5 +583,6 @@ def hdf5collector(

del exp

pbar.close()
f.close()
logger.debug("Data Logging done")

0 comments on commit e9ab542

Please sign in to comment.