mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-21 16:35:07 +00:00
fix(downloader): report rolling speed on the multiprocess progress bar
The parent computed a cumulative average since batch start while every other path shows a SpeedWindow rolling rate, so the MP bar lagged and read differently; use the same rolling window.
This commit is contained in:
@@ -1065,6 +1065,7 @@ def _download_multiprocess(
|
|||||||
total_bytes = 0
|
total_bytes = 0
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
last_speed_report = start_time
|
last_speed_report = start_time
|
||||||
|
speed_window = SpeedWindow(start_time)
|
||||||
done_count = 0
|
done_count = 0
|
||||||
|
|
||||||
dead_ticks = 0
|
dead_ticks = 0
|
||||||
@@ -1118,9 +1119,9 @@ def _download_multiprocess(
|
|||||||
|
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if now - last_speed_report > 0.5 and total_bytes > 0:
|
if now - last_speed_report > 0.5 and total_bytes > 0:
|
||||||
elapsed = now - start_time
|
rate = speed_window.rate(now, total_bytes)
|
||||||
if elapsed > 0:
|
if rate:
|
||||||
yield dict(downloaded=f"{filesize.decimal(math.ceil(total_bytes / elapsed))}/s")
|
yield dict(downloaded=f"{filesize.decimal(math.ceil(rate))}/s")
|
||||||
last_speed_report = now
|
last_speed_report = now
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
DOWNLOAD_CANCELLED.set()
|
DOWNLOAD_CANCELLED.set()
|
||||||
|
|||||||
Reference in New Issue
Block a user