Skip to content

Commit

Permalink
Fix ZeroDivisionError in throughput()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Diemer committed Feb 27, 2024
1 parent eb1901a commit 9e702ab
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions huey_monitor/humanize.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ def throughput(num, elapsed_sec, suffix='', divisor=1000) -> str:
'2.00kBytes/s'
>>> throughput(4, 250, suffix='subtask')
'1.0\xa0minutes/subtask'
>>> throughput(123, 0)
'∞'
"""
if num == 0:
if suffix:
return f'0/{suffix}'
return '0'
if elapsed_sec == 0:
return '∞'
rate = num / elapsed_sec

if rate > 1:
Expand Down

0 comments on commit 9e702ab

Please sign in to comment.