Skip to content

Commit

Permalink
use monotonic for deadline test (#8620)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter committed Apr 15, 2024
1 parent 0e2be4a commit 6be418d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions distributed/tests/test_deadline.py
Expand Up @@ -3,7 +3,7 @@
import asyncio
from time import sleep

from distributed.metrics import time
from distributed.metrics import monotonic
from distributed.utils import Deadline
from distributed.utils_test import gen_test

Expand Down Expand Up @@ -36,21 +36,21 @@ def test_infinite_deadline():

@gen_test()
async def test_deadline_progress():
before_start = time()
before_start = monotonic()
deadline = Deadline.after(100)
after_start = time()
after_start = monotonic()

assert before_start <= deadline.started_at <= after_start
assert deadline.started_at - time() <= deadline.remaining <= 100
assert before_start <= deadline.started_at_mono <= after_start
assert deadline.started_at_mono - monotonic() <= deadline.remaining <= 100

await asyncio.sleep(0.1)
before_elapsed = time()
before_elapsed = monotonic()
elapsed = deadline.elapsed
after_elapsed = time()
after_elapsed = monotonic()
assert (
before_elapsed - deadline.started_at
before_elapsed - deadline.started_at_mono
<= elapsed
<= after_elapsed - deadline.started_at
<= after_elapsed - deadline.started_at_mono
)


Expand Down

0 comments on commit 6be418d

Please sign in to comment.