Skip to content

Commit 90901cb

Browse files
Kachediemol
andauthored
[py] Use monotonic clock for waits, fixes #10544 (#10550)
Co-authored-by: Diego Molina <[email protected]>
1 parent 49fa97d commit 90901cb

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • py/selenium/webdriver/support

py/selenium/webdriver/support/wait.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def until(self, method, message=''):
7272
screen = None
7373
stacktrace = None
7474

75-
end_time = time.time() + self._timeout
75+
end_time = time.monotonic() + self._timeout
7676
while True:
7777
try:
7878
value = method(self._driver)
@@ -84,7 +84,7 @@ def until(self, method, message=''):
8484
screen = getattr(exc, 'screen', None)
8585
stacktrace = getattr(exc, 'stacktrace', None)
8686
time.sleep(self._poll)
87-
if time.time() > end_time:
87+
if time.monotonic() > end_time:
8888
break
8989
raise TimeoutException(message, screen, stacktrace)
9090

@@ -98,7 +98,7 @@ def until_not(self, method, message=''):
9898
``True`` if `method` has raised one of the ignored exceptions
9999
:raises: :exc:`selenium.common.exceptions.TimeoutException` if timeout occurs
100100
"""
101-
end_time = time.time() + self._timeout
101+
end_time = time.monotonic() + self._timeout
102102
while True:
103103
try:
104104
value = method(self._driver)
@@ -109,6 +109,6 @@ def until_not(self, method, message=''):
109109
except self._ignored_exceptions:
110110
return True
111111
time.sleep(self._poll)
112-
if time.time() > end_time:
112+
if time.monotonic() > end_time:
113113
break
114114
raise TimeoutException(message)

0 commit comments

Comments
 (0)