better handling of stalled/overfilled tasks

This commit is contained in:
xenofem 2021-11-23 12:46:16 -05:00
parent 4cf9fb137b
commit ad995b0845

View file

@ -2,6 +2,7 @@
import argparse
import datetime
import math
import subprocess
import sys
import time
@ -94,8 +95,13 @@ while True:
fraction = current / final
value_remaining = final - current
print(' - {} total - {:.1f}% complete'.format(display_value(final), 100*fraction), end='')
if rate > 0:
time_remaining = datetime.timedelta(seconds=(value_remaining / rate))
seconds_remaining = (value_remaining / rate) if rate > 0 else math.inf
if seconds_remaining < 0:
print(' - unknown time remaining', end='')
elif seconds_remaining > 864000:
print(' - stalled', end='')
else:
time_remaining = datetime.timedelta(seconds=seconds_remaining)
eta = datetime.datetime.now() + time_remaining
print(' - {} remaining - ETA {}'.format(
display_timedelta(time_remaining),