Avoid division by zero.

2024-05-20_merge
tecnovert 1 year ago
parent e7ae290eb5
commit d617ab1d6b
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
  1. 8
      bin/basicswap_prepare.py

@ -211,9 +211,13 @@ def make_reporthook(read_start=0):
dl_complete: bool = totalsize > 0 and read >= use_size
time_now = time.time()
time_delta = time_now - time_last
if time_delta < 4 and not dl_complete:
if time_delta < 4.0 and not dl_complete:
return
# Avoid division by zero by picking a value
if time_delta <= 0.0:
time_delta = 0.01
bytes_delta = read - read_last
time_last = time_now
read_last = read
@ -1091,7 +1095,7 @@ def finalise_daemon(d):
d.send_signal(signal.CTRL_C_EVENT if os.name == 'nt' else signal.SIGINT)
d.wait(timeout=120)
except Exception as e:
logging.info(f'Error {e}'.format(d.pid))
logging.info(f'Error {e} for process {d.pid}')
for fp in (d.stdout, d.stderr, d.stdin):
if fp:
fp.close()

Loading…
Cancel
Save