Skip to content

fix potential negative calculation crash - #2

Open
NotoriousPyro wants to merge 1 commit into
nftechie:mainfrom
NotoriousPyro:negative-time-calc
Open

fix potential negative calculation crash#2
NotoriousPyro wants to merge 1 commit into
nftechie:mainfrom
NotoriousPyro:negative-time-calc

Conversation

@NotoriousPyro

Copy link
Copy Markdown

time.monotonic() is called once for the while condition and again for sleep(). If the deadline passes between those calls, until - time.monotonic() becomes negative.

I changed the loop to calculate one remaining duration per iteration and break cleanly when it reaches zero.

This prevents the following rare crash:

{
  "type": "ValueError",
  "reason": "sleep length must be non-negative",
  "locations": [
    "cli.py:333 main"
  ]
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant