Skip to content

Commit 52fa321

Browse files
committed
Use time.monotonic() for elapsed time computation
Refs https://docs.python.org/3/library/time.html#time.monotonic
1 parent 68e39c9 commit 52fa321

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/crate/testing/layer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ def _download_and_extract(uri, directory):
7878

7979

8080
def wait_for_http_url(log, timeout=30, verbose=False):
81-
start = time.time()
81+
start = time.monotonic()
8282
while True:
8383
line = log.readline().decode('utf-8').strip()
84-
elapsed = time.time() - start
84+
elapsed = time.monotonic() - start
8585
if verbose:
8686
sys.stderr.write('[{:>4.1f}s]{}\n'.format(elapsed, line))
8787
m = HTTP_ADDRESS_RE.match(line)
@@ -330,13 +330,13 @@ def tearDown(self):
330330
self.stop()
331331

332332
def _wait_for(self, validator):
333-
start = time.time()
333+
start = time.monotonic()
334334

335335
line_buf = LineBuffer()
336336
self.monitor.consumers.append(line_buf)
337337

338338
while True:
339-
wait_time = time.time() - start
339+
wait_time = time.monotonic() - start
340340
try:
341341
if validator():
342342
break

0 commit comments

Comments
 (0)