Skip to content

running_time_human_readable drops hours once past a day and prints "Up 60 seconds" #77

Description

@sequoiap

pyrolab/manager.py:642-671:

if delta.days > 0:
    return f"Up {delta.days} days"
elif delta.seconds > 3600:
    return f"Up {delta.seconds // 3600} hours"
elif delta.seconds > 120:
    return f"Up {delta.seconds // 60} minutes"
elif delta.seconds > 60:
    return f"Up 1 minute"
else:
    return f"Up {delta.seconds} seconds"

This is the STATUS column of pyrolab ps. Issues:

  • A daemon up for 6 days 23 hours reports Up 6 days. timedelta.seconds is the sub-day remainder, so the hours are available and discarded.
  • delta.seconds == 60 falls through every branch to the final else and prints Up 60 seconds.
  • delta.days == 1 prints Up 1 days.
  • Boundaries use > rather than >= throughout, so each threshold is off by one unit.

Suggested fix: compute from delta.total_seconds() and emit the two most significant units (Up 6d 23h, Up 4h 12m, Up 45s), which is both correct and more informative in a status table. humanize.naturaldelta would also do, though it is another dependency for one function.


Found in a full-codebase audit at v0.4.0 (commit 1ce3146).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions